How to set in Html code 0 as valid value and to display

Viewed 18

I have a question about html code in angular app.

my question ist, is there also the ohter way to check if value null or undefined in a ngif

my code looks like this.

<div ngif= "value !== null and value !== undefinded">
 {{value}}
</div>
  1. question is there the other way to check this if? because there is not only this div.

i can not do this:

<div ngif= "value">
 {{value}}
</div>

because if the value 0 is, ngif return false, But I expect also to display 0.

any better idea?

1 Answers

Simply add exception if it's 0 to ngif="value" if you want to show 0: ngif="value && value !== 0"

Stackblitz

Related