Skip to content

Instantly share code, notes, and snippets.

@djhojd
Forked from NetanelBasal/stop-directive-final.ts
Last active August 25, 2017 12:14
Show Gist options
  • Save djhojd/c3109b5b8e590c4b553a2768fdad1ef7 to your computer and use it in GitHub Desktop.
Save djhojd/c3109b5b8e590c4b553a2768fdad1ef7 to your computer and use it in GitHub Desktop.
import { Directive, Output, EventEmitter, HostListener } from '@angular/core';
@Directive({
selector: '[click.stop],[clickStop]'
})
export class StopPropagationDirective {
@Output("click.stop") stopPropEvent = new EventEmitter();
@HostListener('click', ['$event'])
onClick(event: Event) {
event.preventDefault();
this.stopPropEvent.emit(event);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment