I'm emitting an event from child component to parent component like this
Child Component
export class ItemComponent {
@Output() id = new EventEmitter()
deleteProduct(id) {
this.id.emit(id)
}
}
Child Component tag
<app-product-item (id)="getId($event)"></app-product-item>
Receive the event on my Parent Component
getId(id){
console.log(id)
}
This is working fine.
Now I need to have the same behavior but whit a component that I access by routerLink and not whit a tag like <app-product-item (id)="getId($event)"></app-product-item>
this does not exist because I'm accessing it by routerLink.
Routing config:
const routes: Routes = [
{ path: '', component: WinesComponent },
{ path: 'app-wines', component: WinesComponent },
{ path: 'app-about', component: AboutComponent },
{ path: 'app-wine-detail/:id', component: WineDetailComponent },
{ path: 'app-wine-add', component: WineAddComponent }
];