javascript - Angular JS resolve in a resolve -


what mean resolve in resolve want able resolve user first, , resolve additional info, eg, addressess, contacts, friends.

what have:

.state('website', {             url : '',             abstract : true,             resolve : {                 // request current signed in user >                 current_user : ['auth', function(auth){                     return auth.requestuser();                 }]             },             views : {                 'main' : {                     templateurl : 'template.html'                 }             }         }) 

what i'll following:

.state('website', {             url : '',             abstract : true,             resolve : {                 // request current signed in user >                 current_user : ['auth', function(auth){                     auth.requestuser().then(function(){                        // here want resolve other resources                        // return here?                     });                 }]             },             views : {                 'main' : {                     templateurl : 'template.html'                 }             }         }) 

i'm not sure if possible.

you can inject "resolved" parameters other resolve functions:

resolve: {   current_user: ['auth', function(auth){     return auth.requestuser();   }],    // "svc" here service assume have friends, address, etc...   friends: ["svc", "current_user", function(svc, current_user){      // svc.getfriends can return promise or value      return svc.getfriends(current_user);   }],    address: ["svc", "current_user", function(svc, current_user){      return svc.getaddress(current_user);   }] } 

then, in controller state, can inject current_user, friends, , address parameters:

.controller("websitemainviewctrl", function($scope, current_user, friends, address){    // ... }) 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -