You can only write an expression in ng-click .
The ngClick directive allows you to specify custom behavior when an item is clicked.
But you can write:
<a ng-click="( (navigation.book = book) && bookSvc.showBook(book))" href="#{{book.id}}">{{book.title}}</a>
In this case, navigation.book gets the contents of the book .
Fiddle Demo
Link
We have several options for calling navigation.book = book
What happens if we write:
ng-click="( bookSvc.showBook(book) && (navigation.book = book))"
In this case, if (it seems that bookSvc is a service) bookSvc.showBook(book) returns nothing or false , navigation.book = book will never be executed.
Demo 2 Fiddle
But if bookSvc.showBook(book) returns true , navigation.book = book called.
Demo 3 Fiddle
Maxim Shoustin Nov 11 '13 at 19:42 2013-11-11 19:42
source share