angularjs - Checkbox binding in ng-repeat angular js -
https://jsfiddle.net/bngk/7urrobaa/
<div ng-repeat="item in items" ng-init="item.showcb = item.value == 'true' || item.value == 'false'"> <input type="checkbox" ng-if="item.showcb" ng-true-value="true" ng-false-value="false" ng-model="item.value" ng-checked="item.value == 'true'">{{items[$index].value}}</input> <input type="text" ng-if="!item.showcb" ng-model="item.value"/> </div>
i have problem in binding checkboxes in ng-repeat if have few checked values default values not updated in model , if non-checked default, works value updated in model, holds boolean value though mentioned ng-true-value="true" , ng-false-value="false" string. want string value present in model. please check in fiddle. support.
if have @ documentation: https://docs.angularjs.org/api/ng/input/input%5bcheckbox%5d, can see ng-*-value accepts expression. if put ng-true-value="true"
, sees true expression.
if put ng-true-value=" 'true' "
, knows string.
but mentioned above, there couple of other mistakes in code.
Comments
Post a Comment