How to get multiple image from the server in ionic app?

#1

Hello, I want to get multiple images from the server in my app. So for this, I tried this code:

<div class="one-image" *ngFor="let image of [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]">
<img src="http://mysite.co.in/ionic/{{image}}.jpg">
</div>

Here I have a working code, this way everything working fine but if I have more then 100 images in a folder at that time what to do? every time write image number is not good or is there any way to get all image from a folder in app…please help :slight_smile:

#2

try assigning the array or json data from your server to a variable and then try using *ngFor

var imagedata:any={}
declare your variable globaly
and assign the value you get from your server to your variable then iterate them

1 Like
#3

IN TypeScript:

images:any=
this.http.post(“your server url”,data,options)
.map(res => res.json())
.subscribe(res => {
res.forech((v)=>{
images.push(v.image)
})
},
(err) =>
{
});

InHtml:

</div>
2 Likes