Getting ionic components to wait for data

I have a function that subscribes to a API call that returns data. This works as in the subscribe function I do a console.log and the data displays.

The problem is, in my HTML, I’m using an ionic card and it’s mapped to the data but the data is not being displayed - presumably because the card is displayed before the data is returned.

Is there a way to update the card from within the subscribe so it displays the data AFTER the subscribe returns the data?

Look at using *ngIf to manage the displaying of elements.

Good call! I had used that elsewhere on a different type of component but different realize you could use it on almost all components!

Thank you!

I think it is better to add loader because if you add *ngif in UI user will be confused. It is better to add loader until data is fetched.

1 Like

How do you add a loader?

Use this.
Note: dismiss it when you get the data from the function.