Reputation: 8198
How do I access a property on the $scope
from within the ng-repeat
loop? In the code below, the thumbnail index is set on the controller. The view need to use this property from inside ng-repeat
.
//Controller
$scope.thumbnailIndex = 4;
//View
<div id="album">
<ul id="photosList">
<li ng-repeat="photo in photos">
<img ng-src="{{photo.thumbnails[??].url}}" ng-click="details(photo.id)"/>
</li>
</ul>
</div>
Upvotes: 1
Views: 908
Reputation: 12059
I believe what you are trying to do is this:
<img ng-src="{{photo.thumbnails[thumbnailIndex].url}}" ng-click="details(photo.id)"/>
If your view/include controller is the current scope, then just drop the $scope.
prefix and you can use the variables wherever you want.
Upvotes: 1