This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Inconsistent ng-if behaviour with strings. #7742
Closed
Description
For some reason, when ng-if
directive receives string '0'
the statement is evaluated as false
. I am not sure if this is a bug or a feature, but I believe it's wrong behaviour because it makes ng-if
behave inconsistent. See the following plunker:
http://plnkr.co/edit/GSwxpOyJvCkM66KqqDct
- Any string evaluates to
true
, it's negation evaluates tofalse
. - Integer
0
evaluates tofalse
, it's negation evaluates totrue
. - Integer
1
evaluates totrue
, it's negation evaluates tofalse
.
This is how JavaScript works and I would expect Angular to behave the same way, but in angular template the following is also true:
- String
'0'
evaluates tofalse
, it's negation evaluates also tofalse
.
Expected behaviour:
- String
'0'
evaluates totrue
, it's negation evaluates tofalse
.
If this is really a feature, shouldn't at least the negation evaluate to the opposite value?