You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
I'm upgrading an app to 1.3.0 and was previously redirecting a user to a login page as needed when $routeChangeStart fired by calling $location.path('/login').
With 1.3.0 I see the ability to call preventDefault() now (nice addition), but that completely shuts off $location redirects (such as to a login view). $location.path('/login') does work (when preventDefault() hasn't been called) but it only changes the browser URL but not the view. What's the recommended way of doing a redirect now to another view within $routeChangeStart?
Here's an example of what I'm trying to do (pretty standard with older versions of Angular):
$rootScope.$on("$routeChangeStart",function(event,next,current){if(next&&next.$$route&&next.$$route.secure){if(!authService.user.isAuthenticated){//Was calling this but commenting out to keep it simple: authService.redirectToLogin();//Changes URL but not the view - goes to original view that I'm trying to redirect//away from now with 1.3. Fine with it but interested in understanding the //"proper" way to do it now so login view gets redirected to.$location.path('/login');//event.preventDefault(); //Nice addition! Can't do any redirect when it's called though}}});
I'm assuming there's a different technique now for this type of task in 1.3.0?