0

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="">&nbsp;</option>
                                </select>

                        </div>
Ne AS
  • 1,490
  • 3
  • 26
  • 58
  • since your problem seems a little complex, it's better to provide a runnable example for others to help. – Pengyy May 10 '17 at 01:51
  • @Pengyy thank you and excuse me I can't now provide a runnable. My problem is that in the select no item is selected in the edit mode, even if there is values in `objectA.objectsB`. When I print the `objectB` I can see the whole object. But how can I get it selected in the `select chosen` ?. I wonder if you can help me please – Ne AS May 10 '17 at 02:03

0 Answers0