Using 'No' in Angular ng-show

So I have this piece of code. This element should be shown if the model optionFalse is set, and if not it will not be shown:

<input ng-show="optionFalse" type="radio" name="example_boolean" />{% verbatim %}{{ optionFalse }}{% endverbatim %}

The way I set the optionFalse value is via ng-model:

 <input ng-model="optionFalse" type="text" name="answer_opt_true" value="" />

So if I type something it the text input the radio should appear. It works fine with every keyword, but when I type 'No' the input doesn't appear. Why is that? Is somehow No evaluated to false? If it is so, how can I find a workaround?

The same behaviour is happening when I type 'n'. With othe letters works just fine.


Angular binds ng-show to a boolean value. It needs to be true for an element to show.

Note: Here is a list of values that ngShow will consider as a falsy value (case insensitive): "f" / "0" / "false" / "no" / "n" / "[]"

taken from AngularJs docs

What about checking the length of a text in the input ?

EDIT: Just check the length of the input like in this example

You can make the test explicit so that it shows for other falsy values. Like, this will work for no

<input ng-show="optionFalse != null" type="radio" name="example_boolean" />{% verbatim %}{{ optionFalse }}{% endverbatim %}


<input ng-show="optionFalse != ''" type="radio" name="example_boolean" />{% verbatim %}{{ optionFalse }}{% endverbatim %}

The list of values mentioned before are not case sensitive but are still considered falsy: "f" / "0" / "false" / "no" / "n" / "[]"

Through several of tests it can be seen when leaving a space after the actual "term", the expression will be considered as truthy. Examples: "f " / "0 " / "false " / "no " / "n " / "[] "

This can also be seen in the directive ng-if which is also dependant on truthy and falsy values

Need Your Help

FB return crashes app xcode ios iphone

iphone ios xcode

when intergrating FB to my app it comes up and varifies that its connected but when it comes to going back to the app it crashes,

Toggle Checkbox settings

javascript jquery checkbox toggle

I've a table of elements and each has a line has a checkbox to opt-in or out. As the list of items can be very long i want to offer a "global" checkbox to tick all checkboxes or untick them based o...