Angularjs Examples

AJS Examples

AngularJS $scope.$digest() Function

The AngularJS $digest method is used to start digest life cycle on $scope and children. The $digest method evaluates the watch expressions of the watchers of $scope and its children and if necessary executes the watch actions until no more listeners are firing. AngularJS (if used properly) will handle the digest lifecycle, so don't have to call $digest method manually.

This method will throw 'Maximum iteration limit exceeded.' if the number of iterations exceeds 10.



AngularJS $scope.$digest() Function Example

<!DOCTYPE html>        
<head> <!-- -->        
 <script src="//"></script>         
    <meta charset="utf-8">        
    <title>AngularJS $digest Example</title>        
var app = angular.module('app', []);        
    app.controller("DigestController", function($scope) { 
      $ = 'techstrikers';
      $scope.counter = 0;

      $scope.$watch('name', function(newValue, oldValue) {
        $scope.counter = $scope.counter + 1;
      $scope.Change = function() {
<body style="background-color:#DDE4E9;">        
  <fieldset style="background-color:#DDE4E9;">                    
    <legend>AngulerJS $digest Method Example</legend>         
  <div ng-app="app">              
    <div ng-controller="DigestController">   
      <p style="font-family:Arial;color:yellow;background:steelblue;padding:3px;width:350px;"    
     <input ng-model="name">  
    <button ng-click="childCall()">$digest</button>  
See Live Example