N
N
Nikita Musikhin2015-11-05 21:18:26
Angular
Nikita Musikhin, 2015-11-05 21:18:26

AngularJS preload, how to file it?

Hello, this is the situation, data comes from the server, is transferred to $rootScope in the callback, but due to the fact that this process is asynchronous, all the data that should be loaded on this page from $rootScope does not have time to be initialized, how to postpone this process and do something like a page preload so that the data has time to arrive, calmly rely on $rootScope and then initialize, I will be grateful if you point me in the right direction :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yaroslav Lyzlov, 2015-11-05
@jestoky

odetocode.com/blogs/scott/archive/2014/05/20/using... Routing
has a resolve parameter Route
won't load until (including template) resolve is executed

resolve: {
   preload: function ($http, $rootScope) {
                    retun $http.post().then(function (result) { 
                       $rootScope.someData = result.data 
                    } 
   }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question