Encountering an issue while attempting to parse this code snippet. I need to pass an expression as a parameter in the ng-click
function, but it's not allowing me to do so. If I don't use an expression, then clicking on the album image will clear the src in the
img src="{{image.media.m}}" ng-model="image.media.m"
, making the image disappear. This error is preventing my saveToAlbum
function from functioning correctly.
What would be the correct way to write this? And why is this behavior not permitted?
<ul class="images-list">
<li ng-repeat="image in imageGroup" ng-controller="albumsCtrl">
<img src="{{image.media.m}}" ng-model="image.media.m">
<div class="topDiv">
<img src="img/album.png" ng-click="saveToAlbum({{image.media.m}}, undefined)">
</div>
<div class="bottomDiv" ng-controller="favoritesCtrl">
<img src="img/favorites.png" ng-click="addToFavorites(image.media.m)">
</div>
</li>
</ul>
The error:
Error: [$parse:syntax] http://errors.angularjs.org/1.3.10/$parse/syntax?p0=%7B&p1=invalid%20key&p2=14&p3=saveToAlbum(%7B%7Bimage.media.m%7D%7D%2C%20undefined)&p4=%7Bimage.media.m%7D%7D%2C%20undefined)
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js:6:417
at hb.throwError (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js:190:254)
at hb.object (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js:199:435)
at hb.primary (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js:189:308)
at hb.unary (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js:197:82)
at hb.multiplicative (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js:196:324)
at hb.additive (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js:196:182)
at hb.relational (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js:196:48)
at hb.equality (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js:195:418) <img src="img/album.png" ng-click="saveToAlbum({{image.media.m}}, undefined)">