Load data before entering page. How to?


#1

For example:

I have a tab which called movies. First time I open the tab the data got loaded from Service API call and it takes around 10sec to load whole data.

The question is how to load data before opening the tab so the user doesn’t have to wait 10 sec or so.

Any ideas would be highly appreciated! thank you.


#2

you can display loader for api call.
when you start api call just show loader to user and when you get the data from ajax/json ,hide the loader


#3

You can use provider.

  • create a function in provider to load data from service api and store that data in some variable in provider.(so that you can access that variable in any page by just importing provider)

  • Call that function when you want to load that data.(Maybe in app.component.ts, so that your data will be loaded before you open the tab)

  • And when you open the tab, you can simply use that variable to display data in your tab page.


#4

That’s how it works now. But 10sec loader is not really good for user experience