1

I need to change the class depends on value in angular2

<p class="pull-right" [ngClass]="">Status: {{payment.status}}</p>

For example:

If the status is failed. I need to add class "Fail". If the status is success, I need to change the class as "Success". How do i do this?.

1 Answer 1

1

You can assign class as below as per your status field :

<p class="pull-right" [ngClass]="{ 'failed' : payment.status === 'failed', 'success' : payment.status === 'success'}">Status: {{payment.status}}</p>
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.