Stig Vanbrabant Stig Vanbrabant - 2 months ago 11x
AngularJS Question

Angular: Can't use value of ng-repeat in ng-click

I want to have a div show up when clicked on the title, to do this i wanted to pass the value of the ng-repeat in the ng-click. But for some reason it doesn't get it through.

Here's the code of my list:

<ul id="vak_lijst">

<li ng-repeat="x in vakken.vakken | unique:'vaknaam'" ng-click="vakken.setSelected(x.vaknaam)">

<span>{{ x.vaknaam }}</span>

<div ng-show="vakken.selected = x.vaknaam">

// some content




Here's my script:

vakken.setSelected = function(vaknaam) {
vakken.selected = vaknaam;

Excuse me that some names are in dutch..


You don't need {{ or }} to access variables inside the ng-click:

... ng-click="myControllerMethod(x.vaknaam)">Ga verder</button>