you can use the redirectTo attribute of your route to redirect users in case of an invalid route call:
$routeProvider.when('/:action/view/',{
redirectTo: function(routeParams, locationPath, locationSearch){
var allowed = ['baseball','basketball'];
if(allowed.indexOf(routeParams.action) != -1){
return null;
}
else{
return '/home';
}
}
}
source
share