0

Lets say I have more than 100 schools. And there is a folder in my local PC that has many images of those schools. Image names are according to Schools id's. Imagine that the school has id=223, then inside the image folder there should be one or many images like 223.jpg, 223_1.jpg, 223_2.jpg, 223_4.jpg. It could be one or more i do not know. I take each image from its source directory. My problem is how i know the number of images a school has with respect to its id. So that i put them in an array and show them in for loop.

Like:

image url :

'http://localhost/photoFolder/'
data.attributes.photos = environment.imageUrl + data.attributes.school_id + '.jpg';
<ngb-carousel>
    <ng-template ngbSlide *ngFor="let photo of navbar.infoData.attributes.photos">
        <img class="card-img-top img-fluid w-full" [src]="photo" alt="Okul Fotoğrafı Bulunamadı">
    </ng-template>
</ngb-carousel>
MadMax
  • 306
  • 1
  • 5
  • 17
  • You can make an AJAX call to the back-end and ask for how many images there are for a given ID, or you can loop until a resource is not found and then stop the loop and not show the last "not found" resource. – KungWaz Jan 30 '18 at 11:31
  • I dont know how to do it using AJAX. But your second idea is kind of possible if u go over detail a little. – MadMax Jan 30 '18 at 11:43
  • maybe this can help you? https://stackoverflow.com/questions/27549134/angularjs-ng-src-condition-if-not-found-via-url But you will also have to have a null check in your loop or do it in the controller somehow. – KungWaz Jan 30 '18 at 12:34

0 Answers0