Skip to content

Instantly share code, notes, and snippets.

@irokhes
Created October 9, 2016 11:02
Show Gist options
  • Save irokhes/38cb6a7725a487bd4d323d2a6a232afd to your computer and use it in GitHub Desktop.
Save irokhes/38cb6a7725a487bd4d323d2a6a232afd to your computer and use it in GitHub Desktop.
app.config(function($routeProvider){
$routeProvider
.when('/secretpage' ,{
templateUrl: "templates/secretpage.html",
resolve:{
"check":function(authService,$location){ //function to be resolved, accessFac and $location Injected
if(authService.isAuthenticated()){ //This happens before the page loads
//it's ok to see the content
}else{
$location.path('/'); //redirect user to home if it does not have permission.
alert("You don't have access here");
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment