我用的时候
<input type='text' maxlength='25' required ng-model='ctrl.inputValue'>
Angular向元素添加了几个类,例如ng-valid,ng-invalid,ng-dirty,ng-pristine,允许显示有关验证结果的可视指示符.
在Dart代码中有没有办法达到这些状态?
好的,所以我刚才看到了这个:
原文链接:https://www.f2er.com/angularjs/142526.html<div test> <form name="myForm"> <input type='text' name="myInput" maxlength='25' required ng-model='ctrl.inputValue'> </form> </div>
然后是以下指令/ 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); }); } }
这将输出模型是否有效.
在此处查看NgModel的文档以获取其他字段:
http://ci.angularjs.org/view/Dart/job/angular.dart-master/javadoc/angular.directive/NgModel.html