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

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -