0

I'm studying angular and would like to navigate to another page when I click on the button. it happens to me that when I click they add the component of the second page under the button. I followed a thousand tutorials but I don't get the desired result!

    <a class="card" routerLinkActive="active" routerLink="/prenota" > 
   <span style="margin: 14px;">Prenota</span> </a>


const routes: Routes = [
  { path: 'prenota', component: PrenotaComponent },
  { path: 'visualizza', component: VisualizzaComponent },
];

@NgModule({
  imports: [RouterModule.forRoot(routes, {
    onSameUrlNavigation: 'reload'
  })],
  exports: [RouterModule]
})
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
BenTech
  • 131
  • 1
  • 13

1 Answers1

0

Try this way:

   <a class="card" routerLinkActive="active" routerLink="/prenota"> 
   <span style="margin: 14px;">Prenota</span> </a>
   <router-outlet></router-outlet>