Set a default route in Angular CLI
Apply this code in app.module.ts
{ path: ”, redirectTo: ‘/home’, pathMatch: ‘full’ }
If you have many routes and you want to set home is the default root, then it will easy to set default root home component.
For example:
const routes: Routes = [
{ path: ‘home’, component: HomeComponent },
{ path: ‘about-us’, component: AboutUsComponent },
{ path: ‘contact’, component: ContactComponent },
{ path: ”, redirectTo: ‘/home’, pathMatch: ‘full’ },
];
Question and answer is powered by AnsPress.io