[英]Why ngIf's condition with enum value always returns false
I'm trying to use enum value in ngIf
condition, but it's always evaluated to false
. 我正在尝试在
ngIf
条件中使用枚举值,但始终将其评估为false
。
<ng-container *ngIf='action'>
<td *ngIf="action==action.EDIT">
<button (click)="actionClick(action.EDIT,data.id)">EDIT</button>
</td>
<td *ngIf="">
<button (click)="actionClick(action.DELETE,data.id)">DELETE</button>
</td>
</ng-container>
@Input() public action: Action;
Action: typeof Action;
In your component, create a property and assign your enum : 在您的组件中,创建一个属性并分配您的enum:
enumAction = Action
In your template : 在您的模板中:
*ngIf='action === enumAction.EDIT'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.