I made a custom button component and I am trying to make a directive that can be applied on the button in order to dynamically add some behavior when the user clicks it :
@Directive({
selector: '[appMyDirective]'
})
export class AppMyDirective {
// Here, I inject the button instance
constructor(private button: MyButtonComponent) {
this.button...what()?
}
}
I could add some code on MyButtonComponent where I handle an array of callbacks but I would prefer to avoid that. How can I dynamically handle the click event on MyButtonComponent
without modifying its code?