0

I have a table using ng-repeat, and inside of it a select that uses ng-options:

<tr ng-repeat="variable in variables">
  <td>
    <textarea ng-model="variable.extras">{{variable.extras}}</textarea>
  </td>
  <td>
    <select ng-model="variable.condition" ng-options="text for text in toplevelTriggerConditions($index)">
  </td>

For the select, that toplevelTriggerConditions($index) call basically walks up the previous rows of the table, looks for various conditions, and if they pass grabs the value of that previous row's variable.extras and then returns an array based on that. So if for the extras I put 'one,two,three' then the select has options of one, two, and three.

Visually this appears to work fine, but I'm getting a ton of $scope.infdig errors. By googling I see it's because the array being used with ng-options is dynamic, not static, but I'm not sure how to get around this since the value of the array here has to dynamically change.

Hopefully this makes sense what I've tried to describe.

Scott
  • 163
  • 2
  • 11
  • perhaps you need a directive that sets the array so it isn't being returned from a function within `ng-options` – charlietfl Jul 11 '14 at 20:15
  • The array will dynamically change though whenever they modify the 'extras' variable. I'm trying to figure out how to get a watch on that variable.extras right now and then I could set the array as another property on the variable – Scott Jul 15 '14 at 19:50
  • right but if the array gets changed within controller it should update the DOm and therefore the options – charlietfl Jul 15 '14 at 19:52

1 Answers1

0

I've found a logged bug that matches this description, I think the suggested fix is to upgrade to Angular 1.4.*.

Here is the issue. https://github.com/angular/angular.js/issues/9464

Here is the plunker to test for the issue. http://plnkr.co/edit/Q4EZDPCyAgUMKoWDPmrE?p=preview

In my case, I was returning the same object for each ng-option, except I was sorting it in the function before returning it. Angular didn't like this, so instead I used the angular filter from this SO question AngularJS ngOptions sort array.

<tr ng-repeat="phv in placeHolderValues>
    <td>
        <select ng-model='phv.placevalueId'
                ng-options="t.id as t.name for t in valueOptions(phv) | orderBy:'toString()' ">
        </select>
    </td>
</tr>
Community
  • 1
  • 1
Jarrod Chesney
  • 709
  • 7
  • 5