Forked from NetanelBasal/stop-directive-final.ts
Last active
August 25, 2017 12:14
-
-
Save djhojd/c3109b5b8e590c4b553a2768fdad1ef7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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