Niko Lang
Niko Lang

Reputation: 559

Passing variable in ng-click

I have the variable $id inside the scope. I want to pass it into the function "createPNG" and in this function i want to use this ID to access the downloadContainer.

<button type="button" ng-click="createPNG('{{$id}}')">Create Image</button>
<div ng-attr-id="downloadContainer_{{$id}}"></div>

Angular correctly translates the downloadContainer_{{$id}} to the correct number but the function only passes the string {{$id}}. In an older angularJS Version I did not have this problem.

Upvotes: 2

Views: 1464

Answers (1)

Deblaton Jean-Philippe
Deblaton Jean-Philippe

Reputation: 11388

Simply replace with

<button type="button" ng-click="createPNG($id)">Create Image</button>

Upvotes: 5

Related Questions