RouterModule.forRoot([ { path: 'welcome', component: WelcomeComponent }, { path: '', redirectTo: 'welcome', pathMatch: 'full' }, { path: '**', component: 'pageNotFoundComponent' } ])
Case 1 pathMatch:'full' : in this case, when the application runs on localhost:4200 (or on some server), the default page will be the welcome screen, since the URL will be https://localhost:4200/
If https://localhost:4200/gibberish it will be redirected to the pageNotFound screen due to the wildcard path:'**'
Case 2 pathMatch:'prefix' :
If the routes have { path: '', redirectTo: 'welcome', pathMatch: 'prefix' } , now this will never reach the wildcard route, since each URL will correspond to path:'' defined.
source share