$scope.$apply
will no longer be part of Angular 2. Then how do we let Angular know to update the DOM if any of the bound properties have been changed outside the regular angular execution context?
Taken from a blog post by Minko Gechev:
No more $scope.$apply
But how then AngularJS knows that anything outside it’s execution context has taken a place? Lets think where the changes might come from:
- setTimeout
- setInterval
- prompt (yeah, there are people who still use it…)
- XMLHttpRequest
WebSockets
…
For which the answer is:
I understand that patching the browser built-in javascript functions to notify of any changes to Angular is something that can be done in a relatively safe manner (without introducing subtle bugs) and would be very convenient for the developer. But what about third party APIs (such as jQuery.fadeIn
) or if the browser exposes some new asynchronous API which isn't covered? What's the substitute for old $scope.$apply
?