Skip to content

Instantly share code, notes, and snippets.

@mrded
Created March 11, 2016 14:19
Show Gist options
  • Save mrded/44b55b1f3fbf7121d6b4 to your computer and use it in GitHub Desktop.
Save mrded/44b55b1f3fbf7121d6b4 to your computer and use it in GitHub Desktop.
AngularJS 1.x & ui.router: How to show 404 stage by staying on the same URL.
angular.config(function($urlRouterProvider, $stateProvider) {
$stateProvider.state('404Page', { template: '404' });
$urlRouterProvider.otherwise(function($injector, $location) {
$injector.get('$state').go('404Page', {}, { location: false });
return $location.path();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment