如何在使用基于外部ng-repeat索引的两个(嵌套)ng-repeat时预选择选项

时间:2020-06-02 01:38:54

标签: angularjs select angularjs-ng-repeat option angularjs-ng-options

我尝试根据外部ng-repeat的索引使用两个(嵌套的)ng-repeat来获取预先选择的选项。

我认为我已经接近了,但仍然想念我或者需要其他解决方案(可能是ng-option)。

<div ng-repeat="x in loop"> <!-- loop[1,2,3] so it should iterate 3 times --> 
    <div ng-init="parentIndex = $index"> </div>
    <select ng-model="combo_products">
        <option ng-repeat="option in products_info" selected={{x_or_parentIndex.selected {{option.product_name}} </option> 
        <!-- I want first option selected in first iterate, second option selected in second iterate and so on.
      so basically option should be selected based on index of outer ng-repeat. -->
    </select>
</div>

0 个答案:

没有答案