Reputation: 5851
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.
Upvotes: 0
Views: 1881
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