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

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -