user6644024
user6644024

Reputation:

Check ng-model object length

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

Answers (1)

Ali Baig
Ali Baig

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

Related Questions