I have an ObjectA
including a list of ObjectB
and the relation between the two objects is many to many
:
$scope.objectA = {
name: “”,
objectsB: []
}
At first I load all the existing objectsB
from the ObjectB
table. I put them into the select options
list. Then in the add mode, from a button, I let the user add a new select then he chooses a value. If he adds multiple selects, the selected value of each one is pushed in the $scope.objectA.objectsB
.
The problem I’m facing is in the edit mode. For example, if I want to edit an objectA
that has 3 objectB
, I can see 3 selects in my view but the values are not displayed (the values in the $scope.objectA.objectsB
)
This is my HTML:
<div class="form-group" style="padding-left: 0px;" ng-repeat="objectB in objectA.objectsB">
<select chosen disable-search-threshold="1" ng-model="objectB.id"
ng-options="objectB.id as objectB.name for objectB in objectsB track by objectB.id">
<option value=""> </option>
</select>
</div>