Material: ng-checked generating too many events

Created on 15 Jul 2016  路  5Comments  路  Source: angular/material

ng-checked generating too many events
http://codepen.io/anon/pen/oLpwWo
F12 to console, click a checkbox to see many many many events...

  • Angular Version: v1.5.7
  • Angular Material Version:v1.1.0-rc.5-master-d593229
bug

All 5 comments

I already investigated at that issue a long time ago, and it seems to relate to the inherited native checkbox link function. (See #8284)

thank you

Let's keep it open, since we should be able to fix that.

I'm not sure that this is an issue with Material, but rather Angular's ngChecked directive. You can see that the event fires as often, even if you remove all the checkboxes and you put ngChecked on an empty div.

I decided to invest a little more time into this since I noticed that the digests were being triggered properly when removing the dependency on ngMaterial. It turns out that this concerns other built-in Angular directives and is caused by ngAria (on which Material has a dependency).

Here are a couple of examples. Note that the only difference between the two is dependency on ngAria:

  1. This one only triggers the callback twice on load and then once for every click.
  2. The one triggers 4 digests on load and 2 for each click.

After looking at the source, it seems like ngAria sets up an additional watcher for a specific set of directives, causing the function to be triggered twice. I'll close the issue since this is the intended behaviour, without which ngAria wouldn't work properly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

epelc picture epelc  路  3Comments

nikhildev picture nikhildev  路  3Comments

ghost picture ghost  路  3Comments

WebTechnolog picture WebTechnolog  路  3Comments

reggiepangilinan picture reggiepangilinan  路  3Comments