Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 706
Merge-pony Avatar asked May 05 '17 09:05

Merge-pony


People also ask

Can we use ngIf in Div?

On the div tag we added the ngIf directive that would be displayed if the value of toggleOn is false. After that, we added some dummy paragraphs. This is how to use the ngIf directive. It can be used in all types of use cases and comparisons you can think of in your component template.


1 Answers

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') 
like image 106
Günter Zöchbauer Avatar answered Sep 23 '22 13:09

Günter Zöchbauer