Search Posts

Category: route-provider

routeprovider resolve not restricting access with

how to routeprovider resolve not restricting access with I want to restrict page to only Administrators. I am finding that my auth factory is not completing before resolve returns answer to route. When i follow/watch the code path page gets loaded before the factory finishes. I am thinking i need to do better with promises and /or “.then()”. Any help would be appreciated. Thanks My route code: .when(“/admin”, { templateUrl : “templates/admin.htm”, controller: ‘AdminCtrl’, […]

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 […]