mardi 7 avril 2015

Showing images from different folders inside ng-repeat loop

I have some data (products) served from database inside ng-repeat. Every product has own id and it refers to folder with images. I want to show images for products inside loop but unfortunatelly I can't figure out how to do this with Angular.


I'm using PHP as server side API, and made function for scanning folders by id.


Inside Angular I'm trying to get those images by product id, but it works only for first product iteration. Others don't show any images.



<div ng-repeat="product in products">

<div ng-init="scanImages( product.id )"></div>

<div ng-repeat="image in images">
<img ng-src="path/{{product.id}}/{{image}}" alt="">
</div>

</div>


In controller:



$scope.scanImages = function( productId ) {

$http.get( 'api/images/scan/' + productId ).
success( function( data ) {
$scope.images = data;
});

};


Any idea?


Aucun commentaire:

Enregistrer un commentaire