Redirecting the Router to Another Route

When your application starts, it navigates to the empty route by default. We can configure the router to redirect to a named route by default:

export const routes: Routes = [
  { path: '', redirectTo: 'component-one', pathMatch: 'full' },
  { path: 'component-one', component: ComponentOne },
  { path: 'component-two', component: ComponentTwo }
];

This tells the router to redirect to component-one when matching the empty path ('').

When starting the application, it will automatically navigate to the route for component-one.

results matching ""

    No results matching ""