AngularJS error message
Closed this issue · 1 comments
Hi Michael, thank you for this great tutorial. It works as expected except for one bit.
I have changed the restricted
to false
for the home page to make it available to all users. When I point the browser to localhost:3000
, it takes me to the home page and I'm able to view it, but it's displaying an error message in the console. I've tried it on both Firefox and Chrome, but it's the same problem; for some reason it seems that it's not recognizing next.access
Chrome message:
TypeError: Cannot read property 'restricted' of undefined
at main.js:58
Firefox message:
Error: next.access is undefined
@http://localhost:3000/main.js:58:1
Referring to this line of code:
if (next.access.restricted && !AuthService.isLoggedIn())
in this snippet of code in main.js file:
myApp.run(function ($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();
}
});
});
});
GitHub issues are not for support. Please see the comments section of the blog post as this has already been addressed.