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>
3
  • 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. Commented Jan 30, 2018 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. Commented Jan 30, 2018 at 11:43
  • maybe this can help you? stackoverflow.com/questions/27549134/… But you will also have to have a null check in your loop or do it in the controller somehow. Commented Jan 30, 2018 at 12:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.