简体   繁体   中英

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

描述我的问题的图像

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM