I want to create an gallery form an object.
Angular - typescript
I have this function:
showGallery(index: number) {
let prop = {
images: [
{path: 'https://web-service/attach/file/' + this.PIC[0].guid},
{path: 'https://web-service/attach/file/' + this.PIC[1].guid},
{path: 'https://web-service/attach/file/' + this.PIC[2].guid}
],
index
};
this.gallery.load(prop);
}
And I don't know how to make loop inside this function.
I have an PIC array with GUID's of pictures. PIC is created by API call to database and of course there is always different number of pictures.
Can someone explain me, why I cant do it just like this:
showGallery(index: number) {
let prop = {
images: [
for(var PICs of PIC){
{path: 'https://web-service/attach/file/' + PICs.guid}
}
],
index
};
this.gallery.load(prop);
}
Is that have something in common with scoping?
forloops do not return values....images: this.PIC.map(PICS => ...build your object and return it...)