You can write only expression into ng-click
.
The ngClick directive allows you to specify custom behavior when an element is clicked.
But you can write:
{{book.title}}
In this case navigation.book
gets book
content.
Demo Fiddle
Reference
We have several options here to invoke navigation.book = book
What's happen if we will write:
ng-click="( bookSvc.showBook(book) && (navigation.book = book))"
In this case if (seems like bookSvc
is a service) bookSvc.showBook(book)
returns nothing or false
, the navigation.book = book
will never execute.
Demo 2 Fiddle
But if bookSvc.showBook(book)
returns true
the navigation.book = book
will be invoked.
Demo 3 Fiddle