0

I'm using AngularJS for a webapp, I have a set of images stored on disk and I'm using rest services to retrieve the paths of the images on disk. Now on the client side I have an object which is an array containing the paths of the images.

I would like to know how to iterate this array using javascript on the html to display all the images that this array contains.

This is the code I tried but no luck so far:

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


<img alt=""  data-ng-src="{{product.pathToImage}}" height="300" width="200px">



</div>

Thank you very much in advance.

fgonzalez
  • 3,787
  • 7
  • 45
  • 79
  • Have you tried anything? What sample code can you show us that might help? – Steve Robbins Jan 15 '15 at 21:46
  • And where is your javascript code? Have you looked at your console? – Michelangelo Jan 15 '15 at 21:53
  • Is your view attached to your controller? – Daniel Weiner Jan 15 '15 at 21:55
  • Yes sorry, I have checked to the console and I got Error: [$injector:unpr] Unknown provider: aProvider <- a <- productsFactoryHelper .So apparently the problem is related to minification not to the code itself, anyway the ng-repeat should go in the element that repeats as James Waddington said – fgonzalez Jan 15 '15 at 22:19

2 Answers2

1

Repeat should go on the element that repeats rather than the parent - try this:

<div id="products">
    <img alt="" data-ng-repeat="product in products" data-ng-src="{{product.pathToImage}}" height="300" width="200px">
</div>

Edit - corrected

James Waddington
  • 2,894
  • 2
  • 15
  • 24
0

I think that the attribute is ng-repeat rather than data-ng-repeat, have you the products at your $scope?

<div id="products" ng-repeat="product in products">
    <img alt="" ng-src="{{product.pathToImage}}" height="300" width="200px">
</div>
Lompa
  • 106
  • 4
  • 1
    Actually data-ng-repeat is the official way. – Michelangelo Jan 15 '15 at 21:57
  • @Mikey I didn't know it, where can I find the official way? Because I was using this documentation -> https://code.angularjs.org/1.3.9/docs/api/ng/directive/ngRepeat – Lompa Jan 15 '15 at 22:01
  • 1
    Here is some on the Angular page: https://docs.angularjs.org/guide/directive and there was also a topic http://stackoverflow.com/questions/20862713/angular-ng-repeat-vs-data-ng-repeat. Don't worry you are using the right documentation :) – Michelangelo Jan 15 '15 at 22:06