0

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

georgeawg
  • 48,608
  • 13
  • 72
  • 95

2 Answers2

2

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

Pwner
  • 65
  • 6
1

I 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>
Bill P
  • 3,622
  • 10
  • 20
  • 32