I am trying to access $index
of ng-repeat
and place it inside ng-switch-when
. Here is the last thing I have tried. Small piece of what I am trying to do:
<li ng-repeat="contact in contacts" ng-switch on="MenuSelected">
<span ng-switch-when="$index">{{ contact }} {{$index}}</span>
</li>
MenuSelected
I have define in my controller with 0 for example, and I have 2 contacts for test. I have tried to mix ng
things in different tags and everything fall (just show lines), so I don't think that is the problem. When I remove $index
and place for example 0 everything show up.
you cannot use expressions with
ngSwitch
refrer this doc
this implies that
ng-switch-when="$index"
$index
is treated as a string not as a index valueuse ngIf instead
here is the working Fiddle