AngularJS different size and value select boxes in ng-repeat -


i know issue is, far attempts solve problem not successful. appreciated.

i creating table json data in ng-repeat loop. 1 of table columns represents select boxes, of different values , sizes. select statement inside ng-repeat block.

               <tr ng-repeat="unit in unitsdata">                     <td>{{unit.unitname}}</td>                     <td>{{unit.unittype}}</td>                     <td>                         <select class="form-control" ng-model="unit.unit" ng-options="option.value option.name  option in getunitlistforunittype(unit.unittype)"></select>                     </td>                </tr> 

i getting error: [$rootscope:infdig] 10 $digest() iterations reached. aborting!

based on angular documentation select boxes, problem comes getunitlistforunittype function, created in controller return different lists based on provided parameter. not sure how code corrected.

the issue ng-repeat gets reevaluted each item, calls digest cycle again, error getting.

instead of calling:

getunitlistforunittype(unit.unittype) 

you need somehow have $scope variable, example:

... ng-repeat ... option in unitlist[unit.unittype] 

where have $scope variable called $scope.unitlist list of lists. when setup class initialize list of lists variable , should trick.

$scope.unitlist = {     unit1 : ['item1', 'item2'],     unit2 : ['item3', 'item4'] }; 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -