angularjs - How to ng-checked checkbox in ng-repeat? -
i have list display user reputation census. sigle option radio button use code , work great when user answer , when return on same question check previous answer.
<li ng-repeat="item in items"> <input name="myname" value="{{item.id}}" type="radio" ng-selected="mymodel==item.id" ng-model="mymodel"/>{{item.text}} </li>
but multiple option i've use check box , don't know how write code mantain checked previous answer. use code doesn't work:
<li ng-repeat="item in items"> <input name="myname" checklist-value="{{item.id}}" type="checkbox" ng-checked="mymodel==item.id" checklist-model="mymodel"/>{{item.text}} </li>
any help, please?
update
now have model array multiple value inside (mymodel). following code i'm not able check correct items.
<li ng-repeat="item in items"> <input name="myname" checklist-value="{{item.id}}" type="checkbox" ng-checked="mymodel[$index]==item.id" checklist-model="mymodel"/>{{item.text}} </li>
where error? thanks
try following snipet
<li ng-repeat="item in items"> <input name="myname" type="checkbox" ng-model="ngmodel" ng-checked="mymodel===item.id" ng-true-value="{{item.id}}"/>{{item.text}} </li>
Comments
Post a Comment