Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
@Elijen

Description

@Elijen

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 to false.
  • Integer 0 evaluates to false, it's negation evaluates to true.
  • Integer 1 evaluates to true, it's negation evaluates to false.

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 to false, it's negation evaluates also to false.

Expected behaviour:

  • String '0' evaluates to true, it's negation evaluates to false.

If this is really a feature, shouldn't at least the negation evaluate to the opposite value?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions