mardi 30 janvier 2018

getting the image name and count them in Angular

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>




Aucun commentaire:

Enregistrer un commentaire