[SOLVED] Load View before Data


I want to make my app seem a little bit faster and responsive by begining the page transition animation the moment the user clicks the button and then load the data in it.

It seems now that Ionic waits for the controller to finish processing and then begin the transition, are there ways we can reverse this?

Give me your ideas


The only time that a controller will wait for data is if you’re using a resolve in your state. There are several cases in my app where I lazy load data into a view, so not sure why you’re seeing this behavior.


In my app I am using LocalStorage to store the data, using a service I retrieve the data as json parse them to objects and then apply the appropriate filters before returning them to the controller. The view uses the data in ng-repeat.

I noticed that if I remove the above process the view loads instantly but when introduced it will have a two second delay when I click the button. This leads me to believe that accessing the LocalStorage somehow blocks the rest of the operation until the data becomes available.


If anyone is still following this… what I found out is that LocalStorage is actually blocking other javascript from being executed while it stores or retrieves data, this is not very noticeable until your data becomes large.

To overcome this I found two ways…
first method is to use a promice in the controller and when data becomes available assign it to a watched variable, anglular takes care of populating it for you.

a more formal way of doing it, especially if you know you will have a considerable amount of data, is using a plugin called localForage, you can use it pretty much as you would localStorage but uses async ways and can use multiple storage engines as well so that you can choose what is best for your target device or browser.

You can find it here : https://github.com/ocombe/angular-localForage


Ah, I see. Correct, localStorage is not asyncronous - secure localStorage is, however.


What is secure localStorage? never heard of that b4