Stop event propagation in Angular 2 -
what easiest way stop mouse events propagation in angular 2? should pass special $event
object , call stoppropagation()
myself or there other way. example in meteor can return false
event handler.
if want able add elements without having copy/paste same code on , on again, can make directive this. simple below:
import {directive, hostlistener} "@angular/core"; @directive({ selector: "[click-stop-propagation]" }) export class clickstoppropagation { @hostlistener("click", ["$event"]) public onclick(event: any): void { event.stoppropagation(); } }
then add element want on:
<div click-stop-propagation>stop propagation</div>
Comments
Post a Comment