【发布时间】:2014-10-26 12:10:30
【问题描述】:
朋友,我是 angularjs 新手,请解释为什么 angularjs 验证需要 name 属性
<form name="lform" novalidate>
<input type="text" name="userName" ng-model="userName" required novalidate/>
<span style="color:red" ng-show="lform.userName.$dirty && lform.userName.$invalid">
<span ng-show="lform.userName.$error.required">Username is required.</span>
</span>
<br/>
</form>
如果我删除 name="userName" 代码不起作用,请解释这一点。
Update: If I remove "ng-model" it is not working, but I can change "ngmodel='newName'" is working, please explain this reason also.
【问题讨论】:
标签: angularjs angularjs-validation