0

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>
Maylin Anne
  • 103
  • 2
  • 13

3 Answers3

1

Just without {{}}:

ng-click="passID(x.id)"
Ivan
  • 876
  • 1
  • 8
  • 22
1

correct way of using it is: ng-click="passID(x.id)"

You don't need to use interpolation: {{}}.

Ved
  • 11,837
  • 5
  • 42
  • 60
1

Simply use

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

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

Because ng-click is an Angular directive it can understand the expression, as the element is inside the ng-repeat directive you can directly access the object specified in the ng-repeat

Abdul Mateen Mohammed
  • 1,864
  • 1
  • 12
  • 21