Martin Pascual
Martin Pascual

Reputation: 35

Undefined and Null in *NgIf

Are null, undefined and ""<empty string> value treated similarly by *Ngif? For example, is this: *ngIf = "foo == null"

Treated the same as: *ngIf = "foo == undefined"

If not, is there a simpler way to use *ngIf to not show properties with the value null, undefined, and ""?

Upvotes: 2

Views: 6097

Answers (2)

Santa
Santa

Reputation: 377

You can solve this also by using

null === undefined // false
null == undefined // true

by the use of strict comparison operator

Upvotes: 1

Adya
Adya

Reputation: 1112

You can simply check *ngIf = "foo" that can check undefined and null or empty.

Upvotes: 2

Related Questions