I'm trying to create a Directive that accepts a string to pass to HostListener. Basically a Directive to stop event propagation for any event.
import { Directive, HostListener, Input } from '@angular/core';
@Directive({
selector: '[crmDisableEventPropagation]'
})
export class DisableClickPropagation {
public myStr: string;
@HostListener('click', ['$event'])
public onClick(event: any): void {
event.stopPropagation();
}
}
Right now I have 'click'
hardwired as the HostListener parameter. But I am wondering if there is a way (maybe using generics or something similar) to use this one Directive for any kind of event without having to create a different directive per event.