0

When the page is first loaded, the select binds to the correct value (calculated by ng-init) but as soon as any button is clicked on the page, the select loses its selected value. I'm new to angularJS. What is the reason for the ng-model to be reset? How do I go about fixing this?

<div Ng-repeat="(key, value) in Array | groupBy: 'FieldA'">
  <div Ng-repeat="(k, v) in value | groupBy: 'FieldB'">
    <select Ng-model="v.Selected" 
      Ng-init="v.Selected = ( Items | where: ID: k | first )" 
      Ng-options="item.Name for item in Items track by item.ID">
    </select>
  </div>
</div>
Tom
  • 195
  • 2
  • 12

1 Answers1

0

Although not preferable, I ended up changing to the ng-repeat option method and using ng-Selected as a quick fix.

<select>
<option data-ng-repeat="item in Items" value="{item.ItemId}" ng-selected="item.ItemId == k">{{item.ItemName}}</option>
</select>
Tom
  • 195
  • 2
  • 12