Reputation: 11
I am trying to redirect users who are not logged in to my application to a login page. My code is currently working on all pages except for one.
app.run(['$rootScope', '$location'], function($rootScope, $location){
if(!loggedIn){
var returnTo = $location.path();
$location.search("ReturnTo", returnTo);
$location.path("account/login").replace();
}
}
So far I know that on the page in question the value of $location.path is being updated, but it is not being reflected in my browser's search bar and I am seeing the original page view as opposed to the login page view.
I have seen a lot of suggestions about using $rootScope.apply() but I have not gotten any of them to work either.
Upvotes: 0
Views: 215