How to specify a default state in AngularJS ui-router module -


I'm trying to get it: When the user enters the URL that matches any of the URL patterns The state of the states configured in $ stateProvider should not be set to the default state, which is named for example 'notFound' . Entry into this situation should leave the URL untouched, so the user has an opportunity to fix it. This is the reason that I $ urlRouterProvider.otherwise () . I'm not using . Currently I am working with the following solution: In my main controller, I check that

  $ state.current.name == ''   

If this is the case, then I set the state 'notFound' .

  $ state.go ('notFound', {}, {location: wrong}); However, it seems a bit like a hack because I think it's a way of configuring all modules. Config (), but I do not know how. Any thoughts on this?  

I found a solution of myself: it is possible to use the regular expression for the parameter URL " -Ool "status, as the previous state registered in $ stateProvider :

  $ stateProvider.state ('notFound', { Url: '{path:. *}', TemplateUrl: '/notFound.html'});   

If any other URL pattern does not match, this condition will be selected and the full path can be accessed via $ stateParams.path is.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -