angularjs - Initial state of checkbox? -


running code clicking checkbox returns true or false {{ishidden}} expected. when code run first time {{ishidden}} appear blank. how fix this?

<!doctype html> <html data-ng-app> <head lang="en">     <meta charset="utf-8">     <title></title> </head> <body> hidden: <input type="checkbox" ng-model="ishidden">{{ishidden}} <script type="text/javascript" src="js/angular.js"></script> </body> </html> 

use ng-init directive

<input type="checkbox" ng-model="ishidden" ng-init="ishidden= true">{{ishidden}} 

use true or false in ng-init initialize values on scope

here working plunker


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -