AngularJS documentation给出了使用 $asyncValidators
进行自定义表单验证的示例。他们的示例在验证挂起或出现错误时显示一条消息。我想在表单验证成功时显示一条消息。
据我所知,the form validation API docs表示 $valid
返回一个 bool 值,就像 $pending
或 $error
和 the $q
documentation表示 resolve()
应该使表单返回有效。
Here's a Plunker that doesn't work.为什么表单有效时不显示成功消息?
最佳答案
改变
ng-show="form.name.$valid.username"
至:
ng-show="form.name.$valid"
$valid 是 bool 变量而不是对象
这是一个工作demo
关于javascript - 如何在 Angular 示例中使用 $valid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35207189/