Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ngModelWatch not triggering a second digest when it fires #5258

Closed
dtabuenc opened this issue Dec 4, 2013 · 1 comment
Closed

ngModelWatch not triggering a second digest when it fires #5258

dtabuenc opened this issue Dec 4, 2013 · 1 comment

Comments

@dtabuenc
Copy link
Contributor

dtabuenc commented Dec 4, 2013

When ngModelWatch gets called, it can potentially change the validity of the form control and update the respective controllers.

Code in the template could be potentially binding to these values such as doing {{myForm.$valid}}.

You can see the issue in this plunkr:

http://plnkr.co/edit/MC5NZ0AXlqA3XnNCVyzb?p=preview

The problem is that ever since this commit:

e6d9bea

The watch no longer returns any value. So the current digest will never be marked as dirty even though the watch has performed actions that should require a second pass through the digest loop.

I think the fix is probably just returning the value we get from ngModelGet($scope). This will allow the digest to compare the previous value and mark itself as dirty if necessary.

Does anyone see a problem with this approach? If not I can submit a PR.

@ghost ghost assigned IgorMinar Dec 4, 2013
@IgorMinar
Copy link
Contributor

I can repro the bug and your analysis seems correct.

We'd love to get a PR for this issue. Please follow our contribution guidelines to make accepting your PR more efficient. https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md

dtabuenc pushed a commit to dtabuenc/angular.js that referenced this issue Dec 5, 2013
…propriate

Due to an earlier change, ngModelWatch() no longer returns a value to the
caller. This means the digest loop has no way to tell if the watch actually
modified anything and so can not schedule another pass.

This means any watches that watch form or model controller changes
(e.g. watches on form.$valid) that are scheduled prior to an ngModelWatch()
will not be able to see any changes made therin.

This commit fixes this behavior by returning the latest evaluated ng-model
value.

Closes angular#5258
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
…propriate

Due to an earlier change, ngModelWatch() no longer returns a value to the
caller. This means the digest loop has no way to tell if the watch actually
modified anything and so can not schedule another pass.

This means any watches that watch form or model controller changes
(e.g. watches on form.$valid) that are scheduled prior to an ngModelWatch()
will not be able to see any changes made therin.

This commit fixes this behavior by returning the latest evaluated ng-model
value.

Closes angular#5258
Closes angular#5282
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
…propriate

Due to an earlier change, ngModelWatch() no longer returns a value to the
caller. This means the digest loop has no way to tell if the watch actually
modified anything and so can not schedule another pass.

This means any watches that watch form or model controller changes
(e.g. watches on form.$valid) that are scheduled prior to an ngModelWatch()
will not be able to see any changes made therin.

This commit fixes this behavior by returning the latest evaluated ng-model
value.

Closes angular#5258
Closes angular#5282
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants