I'm using resolves to verify that the user is logged in as follows:
routeProvider.
//...
.when('/dashboard', {
title: 'Dashboard',
templateUrl: 'view/dashboard.html',
controller: 'authCtrl',
resolve: {
auth: function ($q, Session) {
var userInfo = Session.getUserInfo();
if (userInfo) {
return $q.when(userInfo);
} else {
return $q.reject({ authenticated: false });
}
}
}
})
My question is, what does the $ q.when (userInfo); in the above code?
So I understand, you should pass the variable "userInfo" as a parameter in the "routeChangeSucess" event, right?
app.run(["$rootScope", "$location",
function ($rootScope, $location) {
$rootScope.$on("$routeChangeSuccess", function (userInfo) {
console.log(userInfo);
});
//...
Note that I have in the code above a console.log, but when checking the Firefox console, it does not return the user's data, but instead the following:
Object {name="$ routeChangeSuccess", targetScope = h, defaultPrevented = false, more ...}
What's wrong?