angularjs - Accessibility of $index in ng-show -
i try displaying select when previous select checked.
<div ng-repeat="item in collection"> <div ng-show="$index === 0 || $parent.list[$index].nom"> <select ng-model="$parent.list[$index].nom" ng-options="..."></select> </div>
1) <div ng-repeat="item in collection">
i loop through collection , create many selects there item in collection.
2) <div ng-show="$index === 0 || $parent.list[$index].nom">
i want display/hide parent div of selects 2 conditions :
- i show div if index equal 0 (for display first select)
- i show div if current ngmodel contains nom
3) <select ng-model="$parent.list[$index].nom" ng-options="...">
i put dynamic ngmodel each select has own model :
test exemple : have 3 options in select, want give opportunity member choose each option of select.
if member choose option of select 1 seconde select show on , if select option of second select third select show on no more else...
the probleme here : $index in directive ngshow seem's known condition :
$index === 0
but no here :
$parent.list[$index].nom
i think should be:
<div ng-show="$index === 0 || $parent.list[$index - 1].nom"> <select ng-model="$parent.list[$index].nom" ng-options="el el in els"></select> </div>
note, want refer previous item in list
, hence $index - 1
.
Comments
Post a Comment