Developer Snippet Diary

Routing configuration without page refresh which navigation | Angular Router | Angular 15+

Instead of href use routerLink attribute.

home.component.html

<a routerLink="/about">Goto about us</a>
<button >home works!</button>

app.component.html

<router-outlet></router-outlet>

app.module.ts

const routesare:Routes=[
  //{path:'',component:HomeComponent},
  {path:'',redirectTo:'home',pathMatch:'full'},
  {path:'home',component:HomeComponent},
  {path:'about',component:AboutusComponent},
  {path:'**',component:NotfoundComponent},
]
Posted by: R GONDAL
Email: rizikmw@gmail.com