Why does ng-show not work when typing F or N

I am new to AnguarJS and I don’t understand something about ng-show.

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

When the user begins to enter an input field, I expect a colon to appear, followed by everything that is typed. I noticed that when f or n is typed initially, the colon character does not appear until more letters are entered. Why is this?

+8
angularjs angularjs-directive
source share
2 answers

The problem is that angular considers the values ​​"f", "false", "0", "n" and "no" false! There is an open error for this behavior. You can fix this with sza, or you can also do this:

<span ng-show="!!variable.one">:</span> 
+7
source share

The criterion does not look correct, ng-show must be of type boolean . try it

 <span ng-show="variable.one.length > 0">:</span> 
+2
source share

All Articles