zuzuleinen zuzuleinen - 4 months ago 19
AngularJS Question

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