Smokey Dawson
Smokey Dawson

Reputation: 9230

inline if statement not working angular 5

This is minor but I cant for the life of me figure out what is going on... so

I have an inline if statement like so..

<button *ngIf="item?.fields?.assetType !== 'tool' || item?.fields?.assetType !== 'questions'">NEXT</button>

so basically the functionality is.. if the returned data has an assetType of tool or questions don't show the button.. now the behavior works when the data that gets returned has an assetType of tool the button is hidden but when I get data where the assetType is equal to questions the button still shows up..

here is the data that is being returned... as you can see assetType is equal to questions so.. the button should be hidden but it isnt

enter image description here

Im sure the problem is something small I just cant figure it out, any help would be appreciated!

Upvotes: 0

Views: 123

Answers (1)

Kyle Krzeski
Kyle Krzeski

Reputation: 6527

For assetType "questions" in your example above, let's walk through it:

item?.fields?.assetType !== 'tool' TRUE

item?.fields?.assetType !== 'questions' FALSE

Statement would evaluate to TRUE since it's a logical OR.

Upvotes: 1

Related Questions