javascript - angular checkbox does not bind to model -
in controller have member:
$scope.sameoptionsonreturn = true;
and in view:
<input type="checkbox" ng-model="sameoptionsonreturn" ng-checked="sameoptionsonreturn" ng-value="true" ng-change="setreturnoptions" />
but input not bind checkbox; it's true. wrong?
note: removing ng-value="true"
doesn't make difference.
since work in snippet below, have assume there's wrong elsewhere in code.
function supercontroller($scope) { $scope.sameoptionsonreturn = true; } angular.module('myapp', []); angular .module('myapp') .controller('supercontroller', supercontroller)
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script> <div ng-app="myapp"> <div ng-controller="supercontroller s"> <input type="checkbox" ng-model="sameoptionsonreturn" ng-checked="sameoptionsonreturn" ng-value="true" ng-change="setreturnoptions" /> {{sameoptionsonreturn}} </div> </div>
Comments
Post a Comment