Preload data with backend service - how to do?


i’m quite new to angular and ionic. For my first tests i want to create an app to view my invoices, edit them and manage the client data.

I’m struggeling a little bit with getting the data from my preconfigured API. On many websites and blog posts i read about loading the needed data directly when executing the neccessary controller. That means, ‘InvoicesCtrl’ at first loads all the invoices. Tapping on one invoice should show me the details in another controller. So ‘InvoiceCtrl’ loads the specific invoice in a new request. Another invoice loads the data again. And so on. That’s pretty simple and easily maintainable, but is that the best way to do it?

In my city sometimes the network connection is poor and very slow. Everytime i want to load new details about an invoice, the app stucks in loading the new invoice data in a seperate request.

Wouldn’t it be better to preload all the invoice data at the start of the app so i can work with it all the time without the need of loading any data again later? How would i do this? Is there any example of an angular service or factory doing this?

Thanks for your help!

You should preload your data.

Take a look at this tutorial:

I think it will show you everything you need to know.