Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why ng-show doesn't work when F or N is typed

I am new to AnguarJS and there is something I don't understand about ng-show.

I have the following code: http://codepen.io/mars16/full/atGLp

When the user starts to type in the input field, I expect a colon to appear followed by whatever is typed. I have noticed that when f or n is typed in initially the colon character doesn't appear till more letters are typed in. Why is this?

like image 968
Andy Avatar asked Aug 11 '13 22:08

Andy


1 Answers

The issue is that angular considers the values 'f', 'false', '0', 'n', and 'no' to be falsy! There is an open bug for this behavior. You can fix it with sza's approach, or you can also do this:

<span ng-show="!!variable.one">:</span>
like image 170
Marc Litchfield Avatar answered Nov 15 '22 22:11

Marc Litchfield