---
title: "What is $digest and $apply?"  
description: "What is $digest and $apply?"  
author: "ICSM Computer"  
published: 2025-12-28  
updated: 2026-02-12  
canonical: https://www.mindstick.com/forum/162014/what-is-digest-and-apply  
category: "angular js"  
tags: ["angular js"]  
reading_time: 2 minutes  

---

# What is $digest and $apply?

**What is** `$digest` **and** `$apply`**? [explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) with example.**

## Replies

### Reply by Richal Singh

In **AngularJS (1.x)**, `$digest` and `$apply` are core methods used for **change detection** and synchronizing the **model (scope)** with the **view (HTML)**.

## $digest

`$digest()` runs the **digest cycle**, where Angular checks all registered watchers and updates the DOM if model values have changed.

It processes the current scope and its child scopes.

It does **not** evaluate expressions globally.

Angular automatically calls `$digest()` during built-in events like `ng-click`, `ng-model`, `$http`, etc.

### Example:

```typescript
$scope.counter = 0;
$scope.increment = function () {
   $scope.counter++;
   $scope.$digest(); // manually triggering digest
};
```

**Normally,** you don’t call `$digest()` directly unless you know what you’re doing.

## $apply

`$apply()` is used when code runs **outside Angular’s context** (e.g., `setTimeout`, third-party JS). It executes your function and then automatically triggers a `$digest()` cycle.

### Example:

```typescript
$scope.message = "Hello";
setTimeout(function () {
   $scope.$apply(function () {
       $scope.message = "Updated from setTimeout";
   });
}, 2000);
```

## Here:

`$apply()` runs the function.

Then Angular internally calls `$digest()` to update the view.

## Difference (Programming View)

`$digest()` → Performs change detection.

`$apply()` → Executes external code + triggers `$digest()` automatically.

In short, use `$apply()` when updating scope outside Angular; `$digest()` is the internal mechanism that updates bindings.


---

Original Source: https://www.mindstick.com/forum/162014/what-is-digest-and-apply

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
