javascript - Setting ng-model inside ng-repeat not working -
i have list of questions , each question have options checkbox. i'm using ng-repeat list questions , ng-repeat list options. how should set ng-model answer option checkbox selected options questions.
i tried setting ng-model answers[qst.id][ans.id], returning error typeerror: cannot set property '*' of undefined
<div ng-repeat="qst in questions"> <div>{{qst.question}}</div> <div> <ul> <li ng-repeat="ans in answers"> <span> <input type="checkbox" ng-model="answers[qst.id][ans.id]"> </span> <span> {{ans.ansoption}} </span> </li> </ul> </div> </div> what perfect way ?
dont know structure of answers, object (key-value pair), binded checkbox key checked in answer.
<div ng-repeat="qst in questions"> <div>{{qst.question}}</div> <div> <ul> <li ng-repeat="ans in answers[qst.id]"><span><input type="checkbox" ng-model="ans.checked"></span><span>{{ans.ansoption}}</span></li> </ul> </div> </div>
Comments
Post a Comment