javascript - How to use ng-messages with such a input like <input name='user[name]'> -
i new angular, , try use ng-messages form-validate. now, have no problem when use ng-message in following situation:
<form name='loginform' novalidate> <input name='user' required> <div ng-messages=loginform.user.$error> <div ng-message='required'> field required...</div> </div> <form>
but when change name attribute of input,<input name='user[name]' required>
, ng-message not work again. there can me?
form name attributes can populated dynamically. remember, name
attribute reads string, , ng-messages
reads angular expression should evaluated reference $error
object.
since reference obtained through angular expression, can method returns reference.
in case, assuming name attribute looks this:
<form name="loginform"> <input name="{{ user.name }}" required /> </form>
the correct syntax should be:
<div ng-messages="loginform[user.name].$error" ></ div>
Comments
Post a Comment