AngularJS ui-router otherwise to state instead of url?

后端 未结 3 1627
傲寒
傲寒 2021-02-14 04:26

I am using AngularJS and ui-router and in my app.js. I have the following line:

$urlRouterProvider.otherwise(\'/\');

However

3条回答
  •  野的像风
    2021-02-14 04:51

    Just a small improvement to @kdlcruz's answer:

    $urlRouterProvider.otherwise(function($injector){
        $injector.invoke(['$state', function($state) {
            $state.go('404', {}, { location: false } );
        }]);
    });
    

    By doing that, you still able to keep the incorrect the URL and only state is changed.

提交回复
热议问题