The angular app has the routes as follows:
componentRoutes: Routes = [
{path: 'child',
canActivate: [guardService],
component: ParentComponent,
children: [
{path: '', component: nestedChildComponent1},
{path: ':id', children: [
{path: 'child2', component: nestedChildComponent2},
{path: 'child3', component: nestedChildComponent3},
]},
]
},
];
The Parent component is as follows:
@component({
template: <div>
<H3> This is Parent Component </H3>
<button id='button' (click)="buttonClickedHandler()"> click me </button>
</div>
<router-outlet></router-outlet> <--- nested child components go here
})
export class ParentComponent implements OnInit, OnDestroy {
...
}
The button in ParentComponent
is common among all the nested routes. Each nested child component has to provide their own implementation to the buttonclickedHandler
. How should i go about this? Should my nested components extend the ParentComponent or should it implement an interface that provides the buttonclickedHandler
an abstract API?
I referred abstract method in typescript and creating interfaces for angular services posts and i am confused how to go about my problem.