Angular-bootstrap accordion binding question

I have two descents with the same models, one inside the accordion and the other outside. An external snapshot works fine in terms of two-way data binding, but inside the accordion, it seems there is only one-way data binding, in other words, selecting in the user interface does not set the model value. I found a suggestion here that using ng-changewill fix this problem. It is fixed for <textarea>, but not for <select>. Interestingly, this could be a bug in angular-ui . Can someone help on this. Thanks in advance!

outdoor accordion

 <div class="form-group">
              <label class="col-md-2 control-label" for="category">Category</label>
              <div class="col-md-3">
                <select id="category" ng-model="category" name="category" type="text" class="form-control">
                    <option ng-repeat="category in config.categories.sort()"  value="{{category}}">
                    {{category}}</option>
                </select>
              </div>
            </div> 

Inside the accordion

<accordion close-others="false">
    <accordion-group>
 <div class="form-group">
              <label class="col-md-2 control-label" for="category">Category</label>
              <div class="col-md-3">
                <select id="category" ng-model="category" ng-change="setCategory(category)"  name="category" type="text" class="form-control">
                    <option ng-repeat="category in config.categories.sort()"  value="{{category}}">
                    {{category}}</option>
                </select>
              </div>
            </div> 
  </accordion-group>
  </accordion>

My model categoriesis an array of strings:

example:

"categories": [
            "Admin API",
            "Admin License",
            "adminGUI",
            "antennahouse",
            "App Builder",
            "Backup/Restore",
            "Basis"]

ng change function

 $scope.setCategory = function(category) {
     $scope.category = category;
 };
+4
1

- , , ( ) , .

, : ng-. , .

:

$scope.selection = {};

:

<select ng-model="selection.category" ...>

, . DOM . .

+5

Source: https://habr.com/ru/post/1547290/


All Articles