I am using AngularJS and ui-router and in my app.js
. I have the following line:
$urlRouterProvider.otherwise(\'/\');
However
Try This.
$urlRouterProvider.otherwise(function($injector, $location){
$injector.get('$state').go('404');
});
I think you achieved that with this code
$urlRouterProvider.otherwise(function($injector, $location){
$injector.invoke(['$state', function($state) {
$state.go('404');
}]);
});
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.