Original question: (please skip to the EDIT)
I am trying to make images of books which I am receiving clickable.
<div ng-app="myApp" ng-controller="myAppCrtl">
<ul ng-repeat="x in browseBooks">
<div id="{{x.bookId}}">
<li>
<a href="" ng-click=logout()><img style="max-width:100px;" ng-src="{{x.img}}"></a>
<p>{{x.name}}</p>
<p>{{x.price}}</p>
<br>
</li>
</div>
</ul>
</div>
Following the solutions provided here doesn't work, and the link to the angularjs site is broken.
I know the function logout works perfectly, as with button it is executing.
The problem with <a>
tag I am unable to make the image trigger a desired function.
EDIT
I understand what my problem is, ng-repeat creates a child scope for each item in the loop. So trying to access the logout()
method defined in parent scope is not working. ?
Any idea? even replacing "logout()"
with $parent.logout()
isn't working...
EDIT2
It is working, however all changes are local to inner scope...