2
當我使用獲取NG-模型驗證狀態
<input type='text' maxlength='25' required ng-model='ctrl.inputValue'>
角增加了幾個類,如ng-valid
,ng-invalid
,ng-dirty
,ng-pristine
以允許顯示有關驗證結果視覺指示器的元素。
Dart代碼中有這些狀態嗎?
當我使用獲取NG-模型驗證狀態
<input type='text' maxlength='25' required ng-model='ctrl.inputValue'>
角增加了幾個類,如ng-valid
,ng-invalid
,ng-dirty
,ng-pristine
以允許顯示有關驗證結果視覺指示器的元素。
Dart代碼中有這些狀態嗎?
好了,所以我剛纔介紹到這一點:
看看下面的代碼(形式和名稱很重要!):
<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
看起來不錯。我會試試看。 –
類似的問題http://stackoverflow.com/questions/22535472 –