javascript - angularjs checked box in form -


i want when edit user fill field in form automatically. managed fill input , select fields, don't know how checkbox, checked if need checked. matter of fact did after few days solution stopped working nothing has changed. wrote code in way: html

<label><input type="checkbox" value="1" name="admin" ng-model="userdatactr.user.admin"  ng-checked="userdatactr.user.admin">role_cro</label> 

and value of userdatactr.user.admin 1, checkbox isn't checked. tried integer, string, nothing happened.

does can me?

thanks

the value of checkbox boolean- userdatactr.user.admin should either true or false.

<label><input type="checkbox" name="admin"     ng-model="userdatactr.user.admin">role_cro</label> 

reference: https://docs.angularjs.org/api/ng/input/input%5bcheckbox%5d

edit @harris weinstein points out in comment answer below, should not use ng-checked , ng-model together.

reference: https://docs.angularjs.org/api/ng/directive/ngchecked


Comments