Get ng-model validation status in Dart code

前端 未结 1 1485
夕颜
夕颜 2020-12-21 15:29

When I use


A

1条回答
  •  执念已碎
    2020-12-21 16:15

    Okay so I have just looked in to this:

    Take the following code (Form and names are important!):

    Then the following directive/controller/component:

    @NgController (
    selector: "[test]",
    publishAs: "ctrl"
    )
    class TestController {
      String inputValue;
      Scope thisScope;
      TestController (Scope this.thisScope) {
        thisScope.$watch("ctrl.inputValue", () { 
          NgModel inputModel = thisScope["myForm"]["myInput"];
          print(inputModel.invalid);
        });
      }
    }
    

    This will output whether the model is valid or not.

    View documentation for NgModel here for other fields: http://ci.angularjs.org/view/Dart/job/angular.dart-master/javadoc/angular.directive/NgModel.html

    0 讨论(0)
提交回复
热议问题