AngularJS – $$postDigest vs $timeout when DOM update is needed

April 8, 2014

When you need to update the DOM once after dirty checking is over or in other words, fire a callback after the current $digest cycle completes,you can use $$postDigest or $timeout.I’ll try to explain the cons and the pros of  $$postDigest and $timeout. $$postDigest  pros:          1. Fires a callback after the current $digest cycle completes.          2. Great for updating the DOM once after dirty checking is over. cons:          1. $$ means private to Angular, the interface is not stable. usage: //runs immediately after $scope.$digest$scope.$$postDigest(function(){ console.log("post Digest"); }); * it should be noted that...
2 comments