Malik Kashmiri
Malik Kashmiri

Reputation: 5851

Change Boolean values to button in angular 2 client side

Details

I am trying to get data from api and show into the table. One of the columns contains status attribute which return true or false value but I want to show Active or Block buttons instead of this status, ie. if status is true then show delete button and if status==false show active button. How can I able to achieve this in angular 2.

Image

Image describing my problem

Upvotes: 0

Views: 1881

Answers (1)

Bhushan Gadekar
Bhushan Gadekar

Reputation: 13805

You could probably do something like this:

considering status:boolean=true;

in your template you can use *ngIf as:

<div>
    <button *ngIf="status==true">Delete</button>
    <button *ngIf="status==false">Active</button>
</div>

or you could also use ngSwitch too.

Hope this helps.

Upvotes: 1

Related Questions