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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -