yaboiduke yaboiduke - 4 months ago 14
AngularJS Question

AngularJS: Pass binding in ng-click directive

I've called a function on the

ng-click
event from my html but would like to pass the output of an
ng-repeat
as a parameter to that function. INthis case
{{item.url}}
is the output of the
ng-repeat
.

ng-click = "urlSetter({{item.url}})"


Within the
Controller
of the page I have created the relevent function and set it in the
$scope
.

$scope.urlSetter = function(url){
console.log(url);
};


How can I pass the binding to the function?

Answer

Don't use interpolation ({{}}) inside ng-click directive.

ng-click = "urlSetter(item.url)"
Comments