[英]angular 2 client side condition
I am trying to call api on block/unblock Icon button to block and unblock user. 我试图在“阻止/取消阻止图标”按钮上调用api以阻止和取消阻止用户。 Now I want to ask how could I change Icon Image if user active to show unlock image in front of active and vice versa.
现在,我想问一下,如果用户处于活动状态以在活动对象前面显示解锁图像,反之亦然,该如何更改图标图像。
<link href="../../font-awesome-4.6.3/css/font-awesome.min.css" rel="stylesheet" /> <h1>User View </h1> <div class="row"> <div class="panel panel-default"> <div class="table-responsive"> <table class="table table-striped table-bordered"> <thead> <tr> <th class="text-center">First Name</th> <th class="text-center">Last Name</th> <th class="text-center">Email</th> <th class="text-center">Status</th> <th class="text-center">Block/Unblock</th> </tr> </thead> <tbody> <tr *ngFor="let user of _data | paginate: { itemsPerPage: 10, currentPage: p }"> <th>{{user.FirstName}}</th> <th>{{user.LastName}}</th> <th>{{user.Email}}</th> <th>{{ user.IsActive == true ? 'Active' : 'Block' }}</th> <th> <div class="text-center"> <button type="button" class="btn btn-xs " (click)="approvalPendingRequest(user.SubscriptionId)"> <i class="fa fa-unlock" aria-hidden="true"></i> </button> </div> </th> </tr> </tbody> </table> <pagination-controls (pageChange)="p = $event" #api></pagination-controls> </div> </div> </div>
Change class="fa fa-unlock"
to class="fa {{ user.IsActive == true ? 'fa-lock' : 'fa-unlock' }}"
将
class="fa fa-unlock"
更改为class="fa {{ user.IsActive == true ? 'fa-lock' : 'fa-unlock' }}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.