在Dart代码中获取ng-model验证状态
发布时间:2020-12-17 07:36:20 所属栏目:安全 来源:网络整理
导读:我用的时候 input type='text' maxlength='25' required ng-model='ctrl.inputValue' Angular向元素添加了几个类,例如ng-valid,ng-invalid,ng-dirty,ng-pristine,允许显示有关验证结果的可视指示符. 在Dart代码中有没有办法达到这些状态? 好的,所以我刚才看
我用的时候
<input type='text' maxlength='25' required ng-model='ctrl.inputValue'> Angular向元素添加了几个类,例如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> 然后是以下指令/ 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的文档以获取其他字段: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 专家观察 | 王李明:“一步上云:FlexHCS定义新型数据中心”
- 【数据结构】排序算法(一)之直接插入排序,冒泡排序
- twitter-bootstrap – Bootstrap 3将控件添加到面板标题
- twitter-bootstrap – 用于模态的Bootstrap验证器不会重置F
- shell – 在zsh中查找ALT LeftArrowKey解决方案
- angular – 错误:多个模块匹配.使用skip-import选项跳过将
- SHELL脚本编程基础
- scala – 如何在使用sbt和testng时在测试中抛出的异常获得完
- class – 如何在文档中引用实例方法?
- shell-redirect命令输出到ksh的变量和标准输出