I am working partly from this post and this answer.
I have this route:
.state('barcodeQuery', {
url:'/barcode',
templateUrl: templatePath + '_BarcodeQuery.html',
controller: 'BarcodeQueryCtrl',
controllerAs: 'vm',
requireADLogin: true,
resolve: {
user: 'user',
access: function(user){return user.isAdmin().$promise}
}
})
user.isAdmin looks like this:
isAdmin: function() {
return this.getProfile().then(function(data){
// then return the response.
if(data.isadmin) {
return true;
}
else {
return $q.reject(false);
}
});
},
So far as I can tell, everything works to this point. isAdmin() does return the proper response, depending on the user.
Things start to go wrong here:
$rootScope.$on("$stateChangeError", function (event, current, previous, rejection) {
console.log("Is this thing on?");
});
If .isAdmin() rejects the promise, there should be a $stateChangeEror, right? But in my code, that doesn't happen. The console.log("Is this thing on?") line is never reached. No errors, or anything. The page just renders like normal.
I suspect I've been fouled up in a promise somewhere (that's always where I get fouled up), but I don't see it.
Any help? Thanks.