Custom form validation directive to compare two fields

后端 未结 6 816
借酒劲吻你
借酒劲吻你 2020-11-28 08:54

I\'m an angular newbie, and I\'m stumbling over something in how angular\'s form validation directives work.

I know that I can fairly easily add directives to in

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 09:38

    Would a simple comparison suit you?

    
    

    I think a directive would be an overkill if your case is just this. If you do not feel comfortable with the view containing application logic, you can export it in a function of the controller:

    $scope.isMinMaxInalid = function() {
        return $scope.field.min > $scope.field.max;
    };
    

    And the template:

    
    

提交回复
热议问题