Use wildcard to redirect to main sub-route component in angular

Project: codever - File: public-routing.module.ts

The ** wildcard has to be defined as a child of the root you want redirected back to. Thus URLs like will still “point” to

    path: 'snippets/:id',
    component: PublicSnippetDetailsComponent,
    children: [
      // This is a WILDCARD CATCH-ALL route that is scoped to the "/snippets/:snippetid"
      // route prefix. It will only catch non-matching routes that live
      // within this portion of the router tree.
        path: '**',
        component: PublicSnippetDetailsComponent

Reference -

Shared with from 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Subscribe to our newsletter for more code resources and news

Adrian Matei

Adrian Matei
Life force expressing itself as a coding capable human being