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
Post a Comment