angular/angular.js — pull request #3539 by jamestalmage (2013-08-10 04:38:59+00:00)
Title: fix($q): promises should still resolve outside of the $digest/$apply phase

A number of issues have been raised (see #2431) because the current promise implementation has the unexpected behavior of not forwarding execution to the `onResolve` or `onReject` callbacks until the next $digest cycle, nor does it schedule a new cycle.

The currently recommended solution is to wrap all callbacks with $apply, but that is unnecessarily cumbersome (the user will almost always wants $apply called). It becomes increasingly problematic when dealing with longer promise chains, or using third party libraries that expect conventional promises as input.

Closes #2431