2

I am trying to only show a div if certain scenario's happen.


I get 2 parameters

  1. typeOfCollection which can have 2 possible values called branch or courier
  2. duplicate which can have 2 possible values called Y or N

HTML

<div *ngIf="typeOfCollection === '...' && duplicate" === '...'> </div> 

I do not want to show the above div if typeOfCollection is branch and duplicate is N. For any other scenario, I want to show the div. Any idea how I can do it?

0

2 Answers 2

1

I imagine this would do it:

<div *ngIf="!(typeOfCollection === 'branch' && duplicate" === 'N')">...</div> 
Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried?

<div *ngIf="typeOfCollection !== 'branch' || duplicate !== 'N'"> </div> 

2 Comments

yes, that wouldn't work as we need to exclude a scenario, so || will fail in that situation as it checks for on or the other. @jezmck has the solution
That would work too, according to De Morgan's laws !(a && b) is the same as !a || !b, what I wrote.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.