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

Popular posts from this blog

Combining PHP Registration and Login into one class with multiple functions in one PHP file -

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -