Reputation:
Add class if ng-models has length dosnt work
<input id="Id{{regItem.name}}" ng-model='registrationData[regItem.name]'/>
<label for="Id{{regItem.name}}" ng-class="{focused : registrationData[regItem.name].length)}"
Upvotes: 0
Views: 907
Reputation: 3867
Give it a try
ng-class="registrationData[regItem.name] && registrationData[regItem.name].length > 0? 'focused': ''"
But make sure regItem.name
exists on registrationData
object. I have added a simple plnkr for you to play around! It updates the color of a div once you enter something in the textbox.
Upvotes: 1