Last active
June 23, 2020 13:03
-
-
Save schmkr/896766d37877209c71fc to your computer and use it in GitHub Desktop.
angular ui router 404 without redirect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module("app.example", ["ui.router"]) | |
.config(function($stateProvider, $urlRouterProvider) { | |
$stateProvider.state("404", { | |
templateUrl: "errors/notfound.tpl.html", | |
data: { | |
authorizationRequired: false, | |
permissionsRequired: [], | |
bodyClass: "error" | |
} | |
}); | |
// show a not found error if route is unkown, but keep the original url | |
$urlRouterProvider.otherwise(function($injector) { | |
$injector.invoke(function($state) { | |
$state.transitionTo("404", {}, false); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment