//指令定义

@Directive({ selector: `click
-stop-propagation` events: 'stopClick($event)' }) class ClickStopPropagation { stopClick(event:Event) { event.preventDefault(); event. stopPropagation(); } }
//使用
<button (click)="doSomething()" click-stop-propagation>

 

 

参考:

https://github.com/angular/angular/issues/2042

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-05
  • 2022-12-23
  • 2022-03-02
猜你喜欢
  • 2021-09-07
  • 2021-11-05
  • 2022-02-09
  • 2021-07-04
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案