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.

toBoolean returns false if "f" string is passed as argument. That prevents ng-show to evaluate to true when filtering text is "f" string #1229

Closed
@ttsvetko

Description

@ttsvetko

I'm implementing a custom search field that consists of an text input element and a close icon that should appears when there is an entered text into the field. For that particular case i'm using ng-show to display the close icon.

Please see the example:
http://jsbin.com/oquhor/2/edit

Any string except "f", "false", "0", "n" and "no", shows the div element. But if i enter some of the mentioned strings the div element disapears. In other words when i start to type the word "false", when i type "f" letter the div will not be displayed, on typing "a" the div appears, and when i type the whole word "false" the div disappears again.

I took a look at the ng-show directive - it calls toBoolean function that returns false if the passed string is "f", "false", "n", "no" or "0". It is correct to accept "no" string for falsy value, but it is not correct from the javascript perspective where empty sting is evaluated to false, but any non-empty string is evaluated to "true".

I checked and if i use ng-hide instead of ng-show, everything works just fine. But it is supposed to get the same results in the both cases.

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