I'm trying to use angular's resolve when trying to navigate between routes:
when('/user',
{
templateUrl: 'partials/user.html',
controller: 'UserController',
resolve: { auth: RouteAuthenticationCheck }
})
This works fine when I use $http because it returns a promise:
var RouteAuthenticationCheck = ['$http', function ($http){
return $http.get('/login');
}];
But when I use $resolve, it does not.. and this code would not work:
var RouteAuthenticationCheck = ['$resource', function ($resource){
return $resource('/login').get();
}];
What is the appropriate way to uses $resource to resolve when changing routes?
Try returning the promise from the $resource:
var RouteAuthenticationCheck = ['$resource', function ($resource)
{
return $resource('/login').get().$promise;
}];