Created
December 28, 2014 02:52
-
-
Save frozonfreak/0537e0caeef8264b3dd2 to your computer and use it in GitHub Desktop.
Angularjs watching for route change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.run(function($rootScope, $location) { | |
$rootScope.$on( "$routeChangeStart", function(event, next, current) { | |
if ($rootScope.loggedInUser == null) { | |
// no logged user, redirect to /login | |
if ( next.templateUrl === "partials/login.html") { | |
} else { | |
$location.path("/login"); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment