AngularJS $apply comes into play when it invokes digest cycle to watch the scope model changes. Angular wraps the function call within the $scope.$apply. It means it executes a complete new life cycle. If the execution of the function is normal, the changes are reflected in the view and gets updated. $apply works only around AngularJS context,i.e. the angularjs built-in directives do this automatically and reflects the changes we do into the view. But if the change is out of the AngularJS context,i.e if we use any 3rd party library, then we need to explicitly tell angular that some changes are done by wrapping our code into $apply function. For example-
Note:- Sometimes we may get error-‘$digest already in progress’ if we use $apply heavily. To resolve this, we use $timeout or $evalAsync.