accepted answer angular-route asks about ui-router . The accepted answer uses "monolithic" $routeProvider , which requires the ngRoute module (whereas ui-router needs the ui.router module)
the highest rating uses $stateProvider instead and says something like .state("otherwise", { url : '/otherwise'... }) , but I cannot find the mention of βotherwiseβ in the documentation that it binds . However, I see that $stateProvider is mentioned in this answer , which says:
You cannot use only $stateProvider . You need to enter $urlRouterProvider
Where my answer can help you. For me, it was enough to use $urlRouterProvider as follows:
my_module .config([ , '$urlRouterProvider' , function( , $urlRouterProvider){ //When the url is empty; ie what I consider to be "the default" //Then send the user to whatever state is served at the URL '/starting' //(It could say '/default' or any other path you want) $urlRouterProvider .when('', '/starting'); //... }]);
My suggestion is consistent with the ui-router documentation ( this particular version ), where it includes a similar use of the when(...) method (first function call):
app.config(function($urlRouterProvider){ // when there is an empty route, redirect to /index $urlRouterProvider.when('', '/index'); // You can also use regex for the match parameter $urlRouterProvider.when(/aspx/i, '/index'); })
The Red Pea Oct 27 '17 at 20:46 on 2017-10-27 20:46
source share