Is the following code synchronous in AngularJS?
scope.$apply(function(){
console.log('foo');
});
Yes, it is.
$apply() is synchronous, and the browser blocks user input while JavaScript is running on the main thread. Should the user perform multiple input events quickly, the spec guarantees the browser will queue those events.
More here: https://github.com/angular/angular.js/issues/3782