2014-02-16 29 views
2

当我使用获取NG-模型验证状态

<input type='text' maxlength='25' required ng-model='ctrl.inputValue'> 

角增加了几个类,如ng-validng-invalidng-dirtyng-pristine以允许显示有关验证结果视觉指示器的元素。

Dart代码中有这些状态吗?

+0

类似的问题http://stackoverflow.com/questions/22535472 –

回答

2

好了,所以我刚才介绍到这一点:

看看下面的代码(形式和名称很重要!):

<div test> 
    <form name="myForm"> 
     <input type='text' name="myInput" maxlength='25' required ng-model='ctrl.inputValue'> 
    </form> 
</div> 

然后下面的指令/控制器/组件:

@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

+0

看起来不错。我会试试看。 –