How to handle Location bad-path & redirect to default state

252 Views Asked by At

I have state with multiple params. Like below

$urlRouterProvider.otherwise(function ($injector, $location) {
    var $state = $injector.get('$state');
    return $state.go('404');
});

$stateProvider

    // Home
    .state('dashboard', {
        url: '/:primaryId/:moduleType/:modelId',
        templateUrl: "app/dashboard/dashboard.html"
        }
    })


    // Extra
    .state('404', {
        url: '/404',
        templateUrl: "app/page-extra/404.html"
    });

When site opens default it redirects to 404.

And it also works fine with when passing all params in dashboard.

But when customer types http://localhost:3000/#!/// in browser, It gives below error instead of going in dashboard or 404 (if path is invalid).

enter image description here

Can anyone tell me what am i missing here?

0

There are 0 best solutions below