Joined March 2013
·

Elwin Arens

Amsterdam
·
·
·

What @blak3mill3r said.

Instead of creating a hook on $locationChangeStart, create a hook on $routeChangeStart, which is passed the next and current route.

This way you can simply access the requireLogin property, like this:

$rootScope.$on("$routeChangeStart", function(event, next, current) {
    if(next.requireLogin) {
        // Auth/session check here
        event.preventDefault();
    }
});

Hope this helps.

Achievements
34 Karma
0 Total ProTip Views