Stanislav Pyshevskyi
Stanislav Pyshevskyi

Reputation: 1071

Angular2 - can't redirectTo NotFound page

I wanna redirect user to Not found page if user type error url. I saw this post and this page and try in own project. But when I enter somthing get error:

Invalid route configuration of route '/**': path cannot start with a slash

My app.routing.ts

export const routes: Routes = [
    {
        path: 'home',
        component: AppComponent,
        children: [
            {
                path: '',
                component: LoginComponent
            }
        ]
    },
    {
        path: "/**",
        redirectTo: 'home',
        pathMatch: 'full'
    },
]

I wanna redirect to home page if all paths not matches with routes

Upvotes: 0

Views: 635

Answers (1)

micronyks
micronyks

Reputation: 55443

Change to following,

{
        path: "**",
        redirectTo: 'home',
        pathMatch: 'full'
},

Upvotes: 2

Related Questions