Miriam
Miriam

Reputation: 133

ng-if - checking for null value

I have a loop that runs through a data set and determines the folder setup for a href. I have a ng-if for each of the options but I need to add a check to one of the ng-ifs. I need a way to check if a value is null. I have used something like:

 ng-if="!shortcut.SAM3Link" 

The problem with this is that if a value in my database is not null but does not have a value it does not recognize the difference. I need a way to specifically check for null rather than not having a value.

Basically I need a way to determine between a NULL value in my database and text/blank using a ng-if.

Upvotes: 6

Views: 32219

Answers (2)

sp00m
sp00m

Reputation: 48817

You need to use the Strict Equality Comparison:

ng-if="shortcut.SAM3Link === null"

Upvotes: 13

GoutamS
GoutamS

Reputation: 3763

ng-if - checking for null value of Array

  1. ng-if="shortcut.SAM3Link === null"

  2. ng-if="shortcut.SAM3Link.length === 0"

Upvotes: 0

Related Questions