Reputation: 9000
In my Angular app I'm using routes so I've specified my various pages like:
$routeProvider.when('/'...
.when('/login'...
.when('/story'...
However if a user types something not in that list it shows (as expected) a blank ng-view. I'd rather they are redirected to the home page.
How do i do that - "if a page (when
) is not specified in routes direct to homepage"?
Thanks.
Upvotes: 1
Views: 51
Reputation: 890
.otherwise({
redirectTo: '/home'
});
https://docs.angularjs.org/api/ngRoute/provider/$routeProvider
Upvotes: 1
Reputation: 10407
Use the 'otherwise' option in the router:
.otherwise({redirectTo:'/'})
Upvotes: 2