Angular 6 Route with path '**'

4096 views angular
-1

Hi I am new to angular I have a doubt, like I saw a route with { path: '**', redirectTo: ''} why do we use and in which situation. Thanks

answered question

Handle 404 i guess

Handles unspecified routes

1 Answer

3

From the docs:

The ** path in the last route is a wildcard. The router will select this route if the requested URL doesn't match any paths for routes defined earlier in the configuration. This is useful for displaying a "404 - Not Found" page or redirecting to another route.

Where the routes looks like the following:

const appRoutes: Routes = [
  {
    path: 'crisis-center',
    component: CrisisListComponent
  },
  // Other routes
  {
    path: '**',
    component: PageNotFoundComponent
  }
];

posted this

Have an answer?

JD

Please login first before posting an answer.

Ads

Categories