angularjs - angular checkbox using ng-click to reset the ng-model that is binded to the checkbox, thus prevent the checkbox from being unchecked -


i have logic on senario, want first check box alway checked. if user tries uncheck it, want use ng-click change ng-model binded checkbox 'true'. checkbox still being unchecked....

how achieve keep checkbox remains checked based on ng-model's value, without using angular.element(elem).attr("checked", true)

<input type = 'checkbox' ng-model = 'checkboxvalue' ng-click = "handler"/> 

in controller

$scope.checkboxvalue = false; $scope.handler = function(){     $scope.checkboxvalue = true; } 

i want checkbox remain checked since ng-model checkboxvalue true...but apparently missed here

here's plunker:http://plnkr.co/edit/wbjzilfldfbp3mq4omgx?p=preview

i stepped call stack, looks set ng-model true, during $digest, ng-model set based on checkbox's status : checked or unchecked. more 1 way binding: bindding ng-model based on checkbox status?

simply use ng-change instead of ng-click

here demo


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -