AngularJS Form Validation Directive $setValidity on element
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to use $setValidity on an element in a directive. All the examples I've found seem to set it on the controller... I forked a JS fiddle on Form Validation and have tried a bunch of things. Any insights would be most appreciated: http://jsfiddle.net/thomporter/pmKpG/2/ In the fiddle, the $setValidity is called on the controller: ctrl.$setValidity('pwd', true); I'd like to do something like: elm.$setValidity('pwd', true); so that in the form I can do something like: ng-class="{error:form.password.$error.pwd}" 回答1: I figured it out...