0

I'm trying to learn angular by creating some small app.

How do i pass the data in the ng-click directive below from the html to my angular controller function?

<table>
<tr ng-repeat="movie in movies.Search | filter:search | orderBy:'-Year'">
   <td><a ng-href='#here' ng-click="getMovie({{movie.imdbID}})">{{movie.Title}}</a></td>
</tr>
</table

The above way gives me a syntax error. Passing the entire the movie object as getMovie(movie) sends it as a string which I can't access in the controller. I want to pass only the movie.imdbID.

1 Answer 1

1
getMovie(movie.imdbID)

You're already inside an angular expression. So you don't need any mustache.

And no, getMovie(movie) doesn't pass the movie as a string. It passes a reference to the movie object.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.