Loading global variable such as user data before first controller fired

Hello all,

can anyone explain me where to load user data dependent on ajax request what I need everywhere in my app before first controller will be loading? I would like to fill user profile somewhere in app run and use it in controllers by injecting via IOC. The problem is that application isn’t waiting until data is loaded in app run and controllers and views are loading before I response my user data. If I use promise in app run, angular didn’t wait until user data are loaded and render views and fire controllers. If I can make Angular wait before I retrieve data from server, I will can assign response data to rootScope and use it everywhere in my controllers…

I think using resolve in stateProvider is not right way because it is unnecessary duplicationg code.

Thank you for every idea…

This is usually done in resolve property of the top abstract state of your app, all your other states would be children of this parent state.

Have a look at angular-ui router docs, they have examples for this.