In the project I work with Angular, I want it to go to the other component when the button is clicked, but it does not. I connected the navigate method to the button in the menu and wrote the method but it didn't. How can I fix?
.html
<button mat-menu-item (click)="navigate()">Reservations List</button>
.ts
navigate() {
this.router.navigate(['reservationdetail']);
}
.routing
{ path: 'reservationdetail', component: ReservationdetailComponent }
.app module
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HotelComponent } from './hotel/hotel.component';
import { ReservationdetailComponent } from '
./reservationdetail/reservationdetail.component';
import { RezervasyonComponent } from './rezervasyon/rezervasyon.component';
export const routes: Routes = [
{ path: 'hotel', component: HotelComponent },
{ path: "**", redirectTo: "hotel", pathMatch: "full" },
{ path: 'rezervazyon', component: RezervasyonComponent },
{ path: 'reservationdetail', component: ReservationdetailComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }