【问题标题】:Get ng-model validation status in Dart code在 Dart 代码中获取 ng-model 验证状态
【发布时间】:2014-02-19 06:16:44
【问题描述】:

当我使用时

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

Angular 向元素添加了几个类,例如 ng-validng-invalidng-dirtyng-pristine,以允许显示有关验证结果的可视指示符。

有没有办法在 Dart 代码中处理这些状态?

【问题讨论】:

标签: dart angular-dart


【解决方案1】:

好的,我刚刚研究了这个:

获取以下代码(形式和名称很重要!):

<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

【讨论】:

    猜你喜欢
    • 2015-08-13
    • 1970-01-01
    • 2014-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多