Ability to stop event propogation
See original GitHub issueIn the GT codebase, we have a common pattern <ng-click-stop-propogation>
, which provides the same API as <ng-click>, but is implemented as:
(node as Element).onClick.listen((event) {
scope.apply(expression);
event.preventDefault();
event.stopPropagation();
});
We would like a similar pattern in Angular2.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Event Bubbling and Event Catching in JavaScript and React
To prevent other events on the same element from firing, use event.stopImmediatePropagation() instead. It will stop both parents and the same ...
Read more >What's the difference between event.stopPropagation and ...
event.stopPropagation() – It prevents the event from propagating (or “bubbling up”) the DOM. Stops callback execution and returns immediately when called.
Read more >Using stopPropagation() to Stop Event Bubbling in JavaScript
Essentially, stopPropagation() does what the name describes: it stops the propagation of a bubbling event from going further up the tree of ...
Read more >How to stop event propagation with inline onclick attribute in ...
Use HTML DOM stopPropagation() method to stop the event from propagating with inline onclick attribute which is described below:.
Read more >Understanding Event Propagation in JavaScript - MakeUseOf
You can stop the propagation of events using the stopPropagation() method. The addEventListener() method accepts an event name and a handler ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think this is already support in three ways:
false
causespreventDefault()
to run. ie:<div (click)="doSomething(); false">
<button (click)="doSomething(); $event.stopPropagation()">
Then use as:
Request
Do you think the above is not sufficient? If so, how would you imagine the syntax to work?
I think is this.