0

In my Js I did the init $scope.checked = false; and I do the following

<input ng-model="checked" type="checkbox"/>
<button ng-show="checked==true">Save</button>

But it doesn't work, any idea why?

Alice Xu
  • 533
  • 6
  • 20
  • 2
    there isn't enough code here to know for sure what the problem is, but a cardinal rule of angular that everyone should follow is "Always use a dot in `ng-model`.". Because `checked` is a javascript primitive (no dot) rather than an object property (object.property), it is easy to overwrite or hide the value due to Prototype Inheritance. see http://stackoverflow.com/questions/14049480/what-are-the-nuances-of-scope-prototypal-prototypical-inheritance-in-angularjs. I suspect that the checkbox is inside some other element that has a scope, like `ng-repeat` or `ng-form`. – Claies Aug 29 '15 at 14:47
  • 1
    Your code alone works fine http://jsfiddle.net/v3raeufv/ – CodingIntrigue Aug 29 '15 at 14:53

0 Answers0