In my Angular 5 app, the user uploads images to the API, which responds with URL's to the new images. After the promise is completed, I'm able to add the new image objects to the DOM, but the images don't display in the GUI unless I reload the page.
Before page reload:
After page reload:
How can I make the images show without reloading the entire page?
Here's the promise:
this.http.post(`${this.env.api}/v1/images`, formData)
.map(res => res.json())
.catch(error => Observable.throw(error))
.subscribe(
(response) => {
for (let image of response.data) {
this.campaign.images.push(image);
}
},
)
And here's the HTML:
<div *ngFor="let image of campaign.images; let i = index;">
<a [href]="image.web_url" target="_blank">
<img src="{{ image.web_url }}?width=100&height=100">
</a>
</div>