我尝试根据外部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>