javascript - ng-model is being shared inside table due to nested ng-repeat -
i having issues using ng-model inside table. table constructed data got server using restful api service, here details of data using:
- insurance plans fetched server , storing inside
insuranceplans
array - insurance items fetched server , storing inside
insuranceitems
array
note : every insurance plans has list of insurance items!
here html code:
<table class="table" ng-init="$parent.getinsuranceplans();$parent.getinsuranceitems()"> <colgroup> <col> <col ng-repeat="plan in $parent.insuranceplans" class="ng-class: $parent.selectedcol==$index ? 'selected-col' : ''"> </colgroup> <thead> <th></th> <th class="centered-cell" ng-repeat="plan in $parent.insuranceplans">{{plan.name}}</th> </thead> <tbody> <tr ng-repeat="item in $parent.insuranceitems track $index"> <td>{{item.name}}</td> <td class="centered-cell" ng-repeat="plan in $parent.insuranceplans track $index" ng-click="$parent.setselectedcolumn($index)"> <img src="images/check.png" ng-show="$parent.showimg(plan.insuranceitems, item)"></img> <input contenteditable type="checkbox" checklist-model="selectedoptionalitems" checklist-value="item" ng-show="$parent.showcheckbox(item,plan)" id="optional-insurance-plans" name="optionalinsuranceplans"/> <select contenteditable ng-model="selectedfranchiseoption[$parent.$index]" ng-show="$parent.showselectoptions(plan,plan.insuranceitems, item)" class="form-control" name="franchise-options" id="franchise-options" required> <option value="{{0}}">0</option> <option value="{{item.franchise/2}}">{{item.franchise/2}}</option> <option value="{{item.franchise}}">{{item.franchise}}</option> </select> <div ng-show="$parent.showfranchise(plan,plan.insuranceitems, item)" name="franchise" id="franchise">{{item.franchise}}</div> </td> </tr> </tbody> </table>
these ng-show
attributes there reason, don't need pay attention them because 100% sure not relevant problem having.
here initial of table. now, notice privilege insurnace plans have check boxes associated last 4 insurance items, means each insurance item optional each of insurance plans associated item.
- problem: if check insurance item
juridic protection
insurance planprivilage a
here happens:
i aware using nested ng-repeat , each insurance plan contains current insurance itemchecklist-model="selectedoptionalitems"
shared, in other words elements inside same row populated same value. same thing happens when select 1 of options in dropdown menu. here picture of problem aswell:
any kind of appreciated, thank in advance!
Comments
Post a Comment