[英]angular 4: *ngIf with multiple conditions
I'm confused a bit.我有点困惑。 I need to hide block if result have one of several cases.如果结果有几种情况之一,我需要隐藏块。 But seems it not working correctly...但似乎它不能正常工作......
<div *ngIf="currentStatus !== 'open' || currentStatus !== 'reopen' ">
<p padding text-center class="text-notification">{{message}}</p>
</div>
It's just appeared with other condition.它只是以其他条件出现。 It doesn't work neither 1 condition nor for 2. Also tried *ngIf="currentStatus !== ('open' || 'reopen') "
but it's works ok only for 1 case.它既不适用于 1 种情况,也不适用于 2 种情况。也尝试过*ngIf="currentStatus !== ('open' || 'reopen') "
但它仅适用于 1 种情况。
Besides the redundant )
this expression will always be true
because currentStatus
will always match one of these two conditions:除了冗余)
此表达式将始终为true
因为currentStatus
将始终匹配以下两个条件之一:
currentStatus !== 'open' || currentStatus !== 'reopen'
perhaps you mean one of也许你的意思是其中之一
!(currentStatus === 'open' || currentStatus === 'reopen')
(currentStatus !== 'open' && currentStatus !== 'reopen')
You got a ninja ')'.你有一个忍者')'。
Try :尝试 :
<div *ngIf="currentStatus !== 'open' || currentStatus !== 'reopen'">
<div *ngIf="currentStatus !== ('status1' || 'status2' || 'status3' || 'status4')">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.