Reputation: 23321
I'm having an issue with AngularJS where when I use $index it breaks the ng-click function.
This is being done within a div that uses ng-repeat, the repeat code works correctly...
<a class="accordion-toggle" data-toggle="collapse"
data-parent="#acc{{$index}}" ng-click="sayhi('{{ $index }}');"
href="javascript:void(0);"> TEST </a>
When I click, it does nothing. I check the generated HTML and it does have ng-click="sayHi('0')", but the click event doesn't work.
Alternatively, if I change the ng-click to be:
ng-click="sayhi('0');"
without using {{$index}} to generate the zero, it works perfectly...
I've tried with angular 1.0.6 and 1.2.0
Also, I'm using jQuery 1.7 and bootstrap 3.0 if that makes a difference.
Has anyone run into this? If so, what am I doing wrong?
Upvotes: 3
Views: 1418
Reputation: 6317
Try:
ng-click="sayhi($index)"
as ng-click
doesn't support interpolation ({{ }}
) AFAIK only valid angular expressions.
Upvotes: 5