Search Posts

Category: route-provider

Reading property resolve from angular $routeProvider error

I am trying to restrict access to some pages within the public directory using Angular routing. .when(‘/adminprofile’, { templateUrl: ‘../partials/adminprofile.html’, access: {restricted: true} }) I am trying to read what I believe is a property called access which I declared, called access ($rootScope, $location, $route, AuthService) { $rootScope.$on(‘$routeChangeStart’, function (event, next, current) { AuthService.getUserStatus() .then(function(){ if (next.access.restricted && !AuthService.isLoggedIn()){ $location.path(‘/login’); $route.reload(); } }); }); }); But what I get is this error: TypeError: next.access […]

AngularJS router loads template before resolved

I have a route that checks whether a user is logged in, using a HTTP request, and then either allows access or redirects to a welcome page. My problem is that the template is loaded and displayed before the route is resolved, and I don’t think this gives a very good user experience. I can’t figure out why this it. From Googling similar problems it seems like using a promise solved the issue, but I’m […]