Can you prevent an Angular component's host click from firing?

后端 未结 3 1540
我寻月下人不归
我寻月下人不归 2020-12-16 13:00

I\'m creating an Angular component that wraps a native

3条回答
  •  清歌不尽
    2020-12-16 13:25

    I do not believe there is a native way to prevent the event from firing, as supported by this git issue in 2016:

    The order of execution is red herring - the order in which an event on the same element is propagated to multiple listeners is currently undefined. this is currently by design.

    Your problem is that the event exposed to the listeners is the real DOM event and calling stopImmediatePropagation() on the provided event stops execution of other listeners registered on this element. However since all the the listeners registered via Angular are proxied by just a single dom listener (for performance reasons) calling stopImmediatePropagation on this event has no effect.

提交回复
热议问题