Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Angular use capture rather than bubbling to catch events?

Tags:

angular

I somehow need capture method to catch triggered events, but ($event) in template is triggered in bubbling method by default. Is there somewhere to change it?

like image 651
Liranius Avatar asked Apr 06 '17 10:04

Liranius


People also ask

What is the difference between event capturing and bubbling?

With bubbling, the event is first captured and handled by the innermost element and then propagated to outer elements. With capturing, the event is first captured by the outermost element and propagated to the inner elements.

Does event bubbling happen in Angular?

This propagation process is called event bubbling. Events are first handled by the innermost element and then propagate to the outer elements until they reach the root. DOM event bubbling works seamlessly with Angular (plunkr).

How does Angular handle click event?

Events are handled in Angular using the following special syntax. Bind the target event name within parentheses on the left of an equal sign, and event handler method or statement on the right. Above, (click) binds the button click event and onShow() statement calls the onShow() method of a component.


1 Answers

Currently this can only be done adding event handlers imperatively.

There are plans though to support that in the future

See

  • https://github.com/angular/angular/issues/11200
  • https://github.com/angular/angular/pull/13371
  • https://github.com/angular/angular/issues/13248
like image 90
Günter Zöchbauer Avatar answered Sep 21 '22 05:09

Günter Zöchbauer