Posts

Showing posts from May, 2017

Angular Js PracticeDay2 $apply and $digest in Angularjs

Image
$apply and $digest is used to kick-in digest process manually . Mainly used when the scope variable are modified out of "Angular Context"  and /or UI need to refresh its data-bindings $apply behind the scene calls the $digest process $scope.$apply()  and $scope.$digest() $apply() it starts the digest process from the $RootScope ,After  evaluating the RootScope , the process continues through all child scopes and nested scopes one after another the angular events ng-click,$timeout and $http(ajax) etc operations  call $apply $digest - kicks digest process for the current scope (and its child.nested scopes ) only It doesn't starts from the RootScope or ParentScope If called from $Rootscope , it will be equivalent to $apply In the below example ng-model kicks in the digest process which will in turn update the UI Let understand one scenario of using $apply() Lets create the below div element in html <!-- UNDERSTANDING THE DIGEST PROCESS -->