Angularjs Form/Field validation using JavaScript function without directives

前端 未结 4 1549
你的背包
你的背包 2020-12-14 12:54

Is there a way to validate a field in angular without using a directive? For example: I want to make following validation on an input field.

4条回答
  •  一整个雨季
    2020-12-14 13:12

    I'm surprised no one has mentioned ui-validate

    $scope.isOdd = function($value){
      return $value % 2;
    }
    ...
    
    {{myform.value.$error|json}}

    Doesn't get any simpler than that, and it's PROPER AngularJS validation (not silly watches)

    Here's a working demo

提交回复
热议问题