angular 4: *ngIf with multiple conditions

AngularTypescriptAngular2 DirectivesAngular Ng-If

Angular Problem Overview

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>


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.

Angular Solutions

Solution 1 - Angular

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')

Solution 2 - Angular

You got a ninja ')'.

Try :

<div *ngIf="currentStatus !== 'open' || currentStatus !== 'reopen'">


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMerge-ponyView Question on Stackoverflow
Solution 1 - AngularGünter ZöchbauerView Answer on Stackoverflow
Solution 2 - AngularToodooView Answer on Stackoverflow