角度4:* ng如果具有多个条件 [英] angular 4: *ngIf with multiple conditions
本文介绍了角度4:* ng如果具有多个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有点困惑.如果结果有以下几种情况之一,则需要隐藏块.但是似乎无法正常工作...
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>
它只是在其他条件下出现了.它既不适用于1个条件,也不适用于2个条件.也尝试了 * ngIf ="currentStatus!==('open'||'reopen')"
,但仅对1种情况有效.
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.
推荐答案
除了冗余的)
,此表达式始终为 true
,因为 currentStatus
将始终符合以下两个条件之一:
Besides the redundant )
this expression will always be true
because currentStatus
will always match one of these two conditions:
currentStatus !== 'open' || currentStatus !== 'reopen'
也许您是指其中之一
!(currentStatus === 'open' || currentStatus === 'reopen')
(currentStatus !== 'open' && currentStatus !== 'reopen')
这篇关于角度4:* ng如果具有多个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文