Reputation: 49704
If user input a not-existing link, I want the page redirect to Home page.
How can I do it? Thanks
@RouteConfig([
{path: '/home', name: 'Home', component: HomeComponent},
{path: '/about', name: 'About', component: AboutComponent},
{path: '/???', name: 'not-found', redirectTo: ['Home']}
])
Upvotes: 4
Views: 2226
Reputation: 1991
In Routing of the version v4 name property no more exist. route define without name property. so you should use path instead of name redirectTo: '/redirectPath' and no leading slash for path so use path: '404' instead of path: '/404'
like:
{path: '404', component: NotFoundComponent},
{path: '**', redirectTo: '/404'}
Upvotes: 1
Reputation: 6023
This will redirect all unregistered routes to Home
{ path: "/**", redirectTo: ["Home"] }
Upvotes: 7