Maylin Anne Maylin Anne - 1 month ago 8
AngularJS Question

how to use AngularJS value as parameter in function?

I need to pass an ID value once the button is clicked.
but gives me this error: error message

What is the correct way of using:

ng-click="passID({{x.id}})"
?

<table id="Content" ng-repeat="x in images | limitTo:3">
<tr>
<td class="one">
<table>
<tr>
<td><img class="contImage" ng-src="{{x.image}}" ng-alt="{{x.name}}" /></td>
<td class="textAlign">{{x.name}} <button class="viewDetails" ng-click="passID({{x.id}})" type="button">VIEW DETAILS</button></td>
</table>
</td>
<td class="two">{{x.size}}</td>
<td class="one">{{x.storage}}</td>
</tr>
</table>

Answer

Just without {{}}:

ng-click="passID(x.id)"