我有一個ngFor我將所有的數據。現在,如果狀態處於非活動狀態,我需要隱藏一些按鈕。我正在考慮使用ngIf。但我不知道如何寫出這個條件。我如何檢查狀態是否處於非活動狀態併爲這些狀態添加NgIf條件?添加ngIf條件爲ngFor值
<tbody id="address-list" *ngIf="addressData">
<tr *ngFor="let full of addressData " class="{{full.status}}style show-{{full.status}}" data-target="#address-details-modal" data-toggle = "modal" (click)="seperateId(full.ID)">
<td class="{{full.status}}style show-{{full.status}}" >
{{full.address1}} {{full.address2}}
</td>
<td class="{{full.status}}style show-{{full.status}}">
{{full.type}}
</td>
<td class="{{full.status}}style show-{{full.status}}">
{{full.status}}
</td>
</tr>
</tbody>
現在,如果狀態是無效的。當我編輯。我應該隱藏編輯和刪除按鈕。
<div class="modal-footer">
<span class="action-btns" *ngIf="active">
<button class="btn btn-primary btn-md edit-btn pull-left" title="Edits" id="edit-btn-address" (click)="editModal()"><span class="glyphicon glyphicon-pencil"></span></button>
<button class="btn btn-danger btn-md delete-btn pull-left" title="Make Inactive" id="remove-btn-address" (click)="makeInactive()" ><span class="glyphicon glyphicon-trash" ></span></button>
<button type="button" data-dismiss="modal" class="btn btn-default close-btn pull-right">Close</button>
</span>
<span class="edit-btns" *ngIf="edit" >
<button type="button" class="btn btn-default cancel-btn" (click)="editm()">Cancel</button>
<button type="button" data-dismiss="modal" class="btn btn-primary saveEqualBtn save-btn" (click) = "TableUpdate(addressid.ID)" [disabled]="!addressHistory.form.valid" data-dismiss="modal">Save</button>
</span>
<span class="confirm-btns pull-left " *ngIf="inactive" >
<span >Make Inactive?</span>
<button type="button" class="btn btn-sm btn-default no-btn" (click)="makeInactive()" >No</button>
<button type="button" class="btn btn-sm btn-danger yes-btn" data-dismiss="modal" (click)="AddressInactive(addressid.ID)" >Yes</button>
</span>
</div>
爲此,我需要一個ngIf值。所以點擊這些將被隱藏。我怎麼做??
從做ngFor你的對象有不活動的性質? –
是的。一些對象的狀態是不活動的。所以當我點擊它們時,根據狀態按鈕應該隱藏。 – Prakash
@RahulSingh我沒有得到你要求我做的事情?我打開鏈接。我應該登錄嗎? – Prakash