Friday, 15 May 2015

angularjs - UI-router won't resolve promise -



angularjs - UI-router won't resolve promise -

i'm not quite sure i'm doing wrong, seems profile doesn't resolve time mainctrl. user does, resolve. i, perhaps not fetching profile info in auth service?

router:

angular.module('app') .config(function ($stateprovide) { $stateprovider .state('main', { url: '/main', templateurl: 'app/main/main', controller: 'mainctrl', resolve: { user: function (auth) { homecoming auth.getuser(); }, profile: function (user) { homecoming auth.getprofile(); } } }); });

controller:

angular.module('app') .controller('mainctrl', function ($scope, user, profile) { $scope.user = user; $scope.profile = profile; <- doesnt resolve });

auth service:

angular.module('app') .factory('auth', function ($firebasesimplelogin, $firebase, fburl) { var ref = new firebase(fburl); var auth = $firebasesimplelogin(ref); var auth = { user: {}, getuser: function () { homecoming auth.$getcurrentuser(); }, getprofile: function(uid) { homecoming $firebase(ref.child('users').child(uid)).$asobject(); } }; homecoming auth; });

something like

auth.$getcurrentuser()

returns promise need

.then(function(user) {

event before callback complete

in case may resolve on then, like

auth.getuser().then(function(user){ homecoming user; });

also $asobject() needs $loaded() it's promise

var obj = $firebase(ref).$asobject(); obj.$loaded() .then(function(data) {})

angularjs angular-ui-router angularfire

No comments:

Post a Comment