You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
An infinite digest error is thrown when a model is set to NaN and there is an asynchronous validator.
Please check plunker at http://plnkr.co/edit/u9Sq12?p=preview.
When we set model to a string or to null - everything works as expected.
When we set model to NaN there is an infdig error:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.14/$rootScope/infdig?p0=10&p1=%5B%5D
at angular.js:63
at Scope.$digest (angular.js:14281)
at Scope.$apply (angular.js:14506)
at HTMLButtonElement.<anonymous> (angular.js:21443)
at HTMLButtonElement.eventHandler (angular.js:3014)
angular.js:63 Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.14/$rootScope/infdig?p0=10&p1=%5B%5D
This happens because ngModelWatch checks that modelValue !== ctrl.$modelValue, which is true for NaN.
Thus, when we set the model to NaN, $$runValidators is called in every digest cycle. If we have an async validator, it causes a push to asyncQueue and so another cycle is needed.
ngModelWatch returns modelValue, which is NaN so the watch is not considered dirty because $digest() treats NaN as equal to NaN.
I think a good solution would be to treat NaN as equal to NaN in ngModelWatch
Edit:
Check http://plnkr.co/edit/aZZmyP?p=preview ngModelWatch is changed to
An infinite digest error is thrown when a model is set to
NaN
and there is an asynchronous validator.Please check plunker at http://plnkr.co/edit/u9Sq12?p=preview.
When we set
model
to a string or to null - everything works as expected.When we set
model
toNaN
there is an infdig error:This happens because
ngModelWatch
checks thatmodelValue !== ctrl.$modelValue
, which is true forNaN
.Thus, when we set the model to
NaN
,$$runValidators
is called in every digest cycle. If we have an async validator, it causes a push toasyncQueue
and so another cycle is needed.ngModelWatch
returnsmodelValue
, which isNaN
so the watch is not considered dirty because$digest()
treatsNaN
as equal toNaN
.I think a good solution would be to treat
NaN
as equal toNaN
inngModelWatch
Edit:
Check http://plnkr.co/edit/aZZmyP?p=preview
ngModelWatch
is changed toand this indeed solved the infdig
The text was updated successfully, but these errors were encountered: