What is the best approach for having the client redirected to a error route when the API responds with a 404 when trying to load a resource given the parameters in the url, in Angular?
When someone visits for example orders/1, they see the order, but if the either don't have acces, the order is not found or any other exception is happening, how is this best handled?
You could use an intercepter like it is suggested in this question :
Error 401 handling with angularjs
When a resource request will come back from the server, it will hit the interceptor first. You can check the status of the response and react as you want.
You can use the $routeChangeError event
$scope.$on('$routeChangeError', function(arg1, arg2, arg3, arg4){
if(arg4.status == 404) {
$location.url('/my-error-route');
}
});