0

I am created a AngularJs application.I need to change table row background color based on 3 condition.I know to change background color based on 2 condition using following way

<td ng-class="{'red': (variable == 1), 'blue': (variable ==2)}">{{data.material_or_service}</td>

I need to do above using three condition;that is variable==3.is any way to do it.

3
  • 1
    What do you want to achieve? I only see one condition on two separated properties in ngClass. Commented May 14, 2016 at 13:52
  • See this question: stackoverflow.com/questions/18871277/… Commented May 14, 2016 at 14:01
  • Also, if you want another condition, just add another comma and an expression, eg: <div ng-class="{'class1': true, 'class2': true, 'class3': true}"> Commented May 14, 2016 at 14:06

1 Answer 1

2

You can make use of ternary operators like this

<td ng-class="variable === 1 ? 'red' : variable === 2 ? 'blue' : 'green'">{{data.material_or_service}}</td>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.