This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$watchGroup unexpected behaviour #12452
Milestone
Comments
Hm, I think this is indeed the expected behavior. As each expression is considered independently, the new / old values will always reflect the last time the expression has changed. I don't know how difficult it would be to change this - it could also be that there's a performance impact, as you would need to set every expression except that ones that changed newValue === oldValue every time an expression changes. |
I'm closing this due to lack of response. |
3 tasks
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
May 22, 2017
This should help to prevent issues such as angular#8671, angular#12452, angular#16004. Closes angular#12643
3 tasks
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
Jun 29, 2017
This should help to prevent issues such as angular#8671, angular#12452, angular#16004. Closes angular#12643
Narretz
added a commit
to Narretz/angular.js
that referenced
this issue
Jun 29, 2017
This should help to prevent issues such as angular#8671, angular#12452, angular#16004. Closes angular#12643
Narretz
added a commit
that referenced
this issue
Jun 29, 2017
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I've been using $watchGroup to watch a range of fields and trigger a range of functions depending if a particular field has been changed.
I've set up the following plnkr to demonstrate the unexpected behaviour I've came across.
The scenario involves three watched fields and I'd like to trigger a function depending on which field has changed. I've been using the 'newValues' and 'oldValues' to monitor which field has changed.
The problem I've came across is that if I've changed the "Second" field then go and change the "First" or "Third" field, the "Second" function is triggered as its storing the previous 'newValues' and 'oldValues' which makes it look like the "Second" field has changed as demonstrated in this image.
I've highlighted the anomaly in the picture. I'd expect once I started changing the "Third" field, the 'newValues' and 'oldValues' for "Second" to be the same as it isn't the field changing.
The angular documentation for $watchGroup states that watchExpressions is an "Array of expressions that will be individually watched using $watch()". Which makes me think that this isn't intended functionality.
Any clarification if this is a bug or intended functionality would be appreciated.
The text was updated successfully, but these errors were encountered: