What is syntax for routing in angular Basic interview question?

Anil Kumar
Jun 1, 2023

--

index.html

<base href="/"/>

main component template html

<router-outlet> </router-outlet>

main module .ts

Include Lazy loading format

 RouterModule.forRoot(
[
{
path: 'login',
component: LoginComponent
},
{ path: '**',
redirect: 'login',
pathMatch: 'full'
}
{ path: 'welcome',
LoadChildren : import('./welcome/welcome.module').then(m => m.WelcomeModule)
}
......
]
)

setting location strategy to hash

 RouterModule.forRoot(routes, { useHash: true })  

--

--