angular 4: *ngIf with multiple conditions

Merge-pony picture Merge-pony · May 5, 2017 · Viewed 125.6k times · Source

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.

Answer

G&#252;nter Z&#246;chbauer picture Günter Zöchbauer · May 5, 2017

Besides the redundant ) this expression will always be true because currentStatus will always match one of these two conditions:

currentStatus !== 'open' || currentStatus !== 'reopen'

perhaps you mean one of

!(currentStatus === 'open' || currentStatus === 'reopen')
(currentStatus !== 'open' && currentStatus !== 'reopen')