how can I add extra condition on below code
<div ng-class="{true: 'complete'}[item.Id != 0]"></div>
here I need to add "{true: 'abc'}[item.name == "FName"], can anyone help me out.
thank you
After doing a quick search i found this:
ng-class="{'test': obj.value1 == 'someothervalue' || obj.value2 == 'somethingelse'}"
Source: AngularJS ngClass conditional Credits go to https://stackoverflow.com/users/736482/bertrand
<div ng-class="{true: 'complete'}[item.Id != 0],{true: 'abc'}[item.name == "FName"]"></div> here abc is class, but here second condition is not workingI guess that you want complete class to be added with this condition: item.Id != 0. The correct syntax for this is the below:
<div ng-class="{ 'complete': item.Id != 0 }"></div>
You can add as many classes you want using a comma:
<div ng-class="{ 'complete': item.Id != 0, 'abc': item.name == 'FName' }"></div>
true: 'abc'is not a condition...ng-class=" (item.id != 0 && /* some other condition*/) ? 'classNameWhenConditionsMet' : 'classNameWhenConditionsAreNotMet'"is what you are looking for ?