I'm trying to figure out how to retrieve a user, check a boolean's value on that user's record and redirect the user based on the boolean value. If the boolean's value is true, send them somewhere else, if it's not keep doing what you're doing. The following works, but prior to the redirect it briefly shows the the profile page which I don't want to have happen. I want to grab the user, check if they are provisional and if they are redirect them before they ever see the profile page. I'm guessing there needs to be another promise in here somewhere that's fulfilled after the user is checked to be provisional or not? Could use an example.
.when("/:id", {
templateUrl: "pages/profile.html",
controller: "UsersCtrl",
resolve: {
breadcrumb: function() {
return "PROFILE";
},
user: function(User, $route) {
User.get({id: $route.current.params.id}).$promise.then(function(data) {
if (data.provisional) {
window.location = "http://www.google.com";
} else {
// do something else
}
})
}
}
})