Wildcard for angular 2 router does not work properly

If I enter the URL structured as localhost: 3000 / something, the application is correctly redirected to localhost: 3000 / login, but if I enter the URL in the form localhost: 3000 / something / something, the application crashes because the router not redirect correctly.

I installed the router file as follows:

@NgModule({ imports: [ RouterModule.forRoot([ { path: '', redirectTo: '/login', pathMatch: 'full' }, { path: 'login', component: LoginComponent }, { path: '**', component: PageNotFoundComponent }, ]) ], exports: [ RouterModule ] }) export class AppRoutingModule {} 

I am using the HTML5 URL style in my Angular 2 application.

How can I set a wildcard to show user 404's page when he logs in, when he logs in to a URL like localhost: 3000 / something / something?

+5
source share

Source: https://habr.com/ru/post/1258696/


All Articles