angularjs - Restangular ui.router resolve asynchronous or synchronous -


i using restangular , ui.router.

below code.

app.config(["$urlrouterprovider", "$stateprovider", "$locationprovider","restangularprovider",             function ($urlrouterprovider, $stateprovider, $locationprovider, restangularprovider ) {                 $urlrouterprovider.otherwise("/");                 $stateprovider                     //                     .state("home", {                         url: "/",                         templateurl: 'app/class/html/classlist.html',                         controller: 'classsectionlistctrl vm',                     resolve: {                         acyear: function (restangular, $stateparams) {                             return restangular.all('currentyear').getlist();                         },                         classsectionsubjectmatrix: function (restangular, $stateparams) {                             return restangular.all('classsectionsubjectmatrix').getlist();                     }                  } 

i have 2 resolve return acyear & classsectionsubjectmatrix. question is, both acyear & classsectionsubjectmatrix trigger @ same time (parallel) or in sequential manner (first acyear classsectionsubjectmatrix) ?

second,is there way capture how time both acyear & classsectionsubjectmatrix taking start end independently in controller?

something .

acyear                          ---> 0%....10%.....30%........60%.......100% classsectionsubjectmatrix       ---> 0%...........50......100%  restangularprovider.addresponseinterceptor(                     function (data, operation, what, url, response, deferred) {                         pendingrequests--;                         if (pendingrequests == 0) {                             console.log('loaded data2 (hide indicator)' + json.stringify(what));                         }                         return data;                     }); 

first of not resolve on state resolve...

if want pass promise believe using service better. assume want resolve promise on state resolve , return resolved object controller.

there no order between resolve variables unless 1 of them depends on others. means in case can think both start @ same time

resolve: {             acyear: function (restangular, $stateparams) {                return restangular.all('currentyear').getlist().then(function(response){                   return response;                });             },             classsectionsubjectmatrix: function (restangular, $stateparams) {                return restangular.all('classsectionsubjectmatrix').getlist().then(function(response){                   return response;                });             } } 

but if 1 of them depend other should wait dependent value resolved first

resolve: {             acyear: function (restangular, $stateparams) {                return restangular.all('currentyear').getlist().then(function(response){                   return response;                });             },             classsectionsubjectmatrix: function (acyear, restangular, $stateparams) {                return restangular.all('classsectionsubjectmatrix').getlist().then(function(response){                   return response;                });             } } 

in 1 acyear should resolved first second request made classsectionsubjectmatrix...

for second question cannot calculate time on controller resolving them in state...


Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -