Skip to content

Angular NG0100: ExpressionChangedAfterItHasBeenCheckedError — Fix

What NG0100 actually means, why it only shows up in dev mode, why Angular 22's OnPush default can hide it completely, and the fixes that remove the bug instead of silencing it.

angular angular-errors ExpressionChangedAfterItHasBeenCheckedError
BKG
Reading Progress

On This Page

1. The error

You run ng serve, open the console, and see this:

ERROR RuntimeError: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'Loading'. Current value: 'Ready'. Expression location: _App component. Find more at https://v22.angular.dev/errors/NG0100
    at throwErrorIfNoChangesMode
    at bindingUpdated
    at interpolation1
    at ɵɵtextInterpolate1
    at App_Template
    at executeTemplate
    at refreshView
    at detectChangesInView

Two parts of that message matter. Expression location tells you which component's template holds the binding. Previous value / Current value tells you what that binding read the first time and what it read the second time. The exact wording has shifted a little between releases (older ones print the error without the NG0100 prefix), so search your logs for the code, not the sentence.

You won't see this in a production build. The check only exists in dev mode and is stripped out by ng build. That doesn't make it harmless. In production the page keeps showing the value from the first pass ('Loading' here) until something else triggers change detection. The error is Angular telling you that your UI and your state have drifted apart.

The official page is https://angular.dev/errors/NG0100.

2. Reproducing it

Start a fresh project:

npx @angular/cli@latest new repro --defaults
cd repro
npx ng version

Replace src/app/app.ts with:

import { AfterViewInit, ChangeDetectionStrategy, Component } from '@angular/core';

@Component({
  selector: 'app-root',
  changeDetection: ChangeDetectionStrategy.Eager, // remove this line later and watch what happens
  template: `<p>Status: {{ status }}</p>`,
})
export class App implements AfterViewInit {
  status = 'Loading';

  ngAfterViewInit() {
    this.status = 'Ready';
  }
}

Run ng serve, open the console, and the error from section 1 shows up on first load.

Now delete the changeDetection line and reload. The error goes away. That isn't because the bug is fixed. The page now says "Loading" forever, and Angular has nothing to say about it.

That's the most important thing to know about NG0100 in 2026, and I come back to it in section 5.

There are a few other ways to trigger it. All of these were tested with Eager components:

A parent reads child state through @ViewChild.

template: `<p>Status: {{ child?.status }}</p><app-child />`
// ...
@ViewChild(ChildComponent) child?: ChildComponent;

This throws Previous value: 'undefined'. Current value: 'Loading' without any hook writing anything. On the first pass the query hasn't resolved yet, so child is undefined. It resolves before the second pass.

A child's ngOnInit writes to its parent.

// parent template: <p>{{ count }}</p><app-kid />
export class Kid implements OnInit {
  parent = inject(Parent);
  ngOnInit() { this.parent.count++; }
}

This throws Previous value: '0'. Current value: '1'. People are often told that ngOnInit is "safe". That's true for a component's own state. It isn't true for its parent's, because the parent's binding has already been evaluated by the time the child initialises.

A binding that returns something different every time.

get r() { return Math.random(); }   // {{ r }} -> throws every time

You'll often see Date.now() used as the example for this. In my runs {{ now }} with Date.now() did not throw, because both passes ran inside the same millisecond. It's the same bug, but it only fails occasionally, which makes it worse.

3. What changed across versions

The check itself has barely changed in years. What has changed is how likely you are to see it.

AngularWhat matters for NG0100
v18Zoneless arrives as experimental (provideExperimentalZonelessChangeDetection).
v19Components are standalone by default.
v20Zoneless moves to developer preview and is renamed provideZonelessChangeDetection; it becomes stable in 20.2. provideCheckNoChangesConfig lands in developer preview.
v21New apps are zoneless by default. Vitest becomes the default test runner. In 21.2, ChangeDetectionStrategy.Eager is added and Default is deprecated.
v22Components with no changeDetection setting are now OnPush. ng update adds changeDetection: ChangeDetectionStrategy.Eager to existing components that didn't set one, so upgraded apps behave the same. Requires TypeScript 6; Node 20 is no longer supported.

Check https://angular.dev/reference/versions for exact Node and TypeScript ranges, and https://angular.dev/reference/releases for which majors are still supported.

The practical effect: on a v22 project, any new component you write is OnPush, and (see section 5) the normal dev-mode check doesn't re-check OnPush views that aren't marked dirty. Unless you turn on exhaustive checking, you'll see NG0100 less often while the underlying bug keeps happening.

4. Why it happens

Angular's rule is that data flows one way during a render. A change detection pass walks the component tree from parent to child, evaluates each binding and updates the DOM.

In dev mode Angular then does a second, read-only walk (checkNoChanges). It evaluates the same bindings again and compares each one to the value it just rendered. If any of them differ, something changed state during the render, after that part of the page had already been drawn. Angular throws instead of quietly showing you a page that doesn't match your data.

So every NG0100 comes down to the same thing: some code changed a value that an already-rendered binding depends on, in the middle of a render. Usually that code is a lifecycle hook, a child writing to its parent, or a binding that isn't stable.

5. Under the hood

Ivy compiles each template into a function made of instructions. Interpolations like {{ status }} become ɵɵtextInterpolate…, and property bindings become ɵɵproperty. Every binding has a slot in the component's LView, and bindingUpdated compares the new value to the stored one.

In the normal pass, the comparison is Object.is. A difference means "update the DOM and store the new value".

In the checkNoChanges pass, the same template function runs again, but a difference goes to throwErrorIfNoChangesMode. That's why the stack trace points at App_Template and not at your hook. The template is where the problem gets detected. The hook is what caused it.

The comparison in the second pass is also looser than Object.is. Arrays and other iterables are compared item by item, and two different object instances are treated as equal. I checked this: a getter returning a fresh { a: 1 } or a fresh [1, 2] on every call doesn't throw. So NG0100 only catches changes that are actually different values, not every new reference.

For the repro in section 2, the order of events is:

  1. App's template runs. status is 'Loading'; that's stored and rendered.
  2. Child views are refreshed and view queries resolve.
  3. ngAfterViewInit runs and sets status = 'Ready'.
  4. The dev-mode second pass evaluates {{ status }}, gets 'Ready', compares it to 'Loading', and throws.

Why OnPush hides it

During the second pass Angular only re-checks views it would refresh in a normal pass. An Eager view is always checked. An OnPush view that isn't marked dirty is skipped, so its stale binding is never compared and nothing is thrown.

That's exactly what happened when I removed the Eager line. The page rendered Status: Loading, no error, and since this is a zoneless app with a plain field, nothing ever told Angular to render again.

You can make the dev check strict again:

import { provideCheckNoChangesConfig } from '@angular/core';

providers: [provideCheckNoChangesConfig({ exhaustive: true })]

With exhaustive: true, every view is treated as if it were Eager during the check, and the same OnPush component throws NG0100 again with 'Loading' / 'Ready'. The API also accepts an interval option that re-runs the check periodically. It's in developer preview, so it belongs in dev builds and tests, not production.

Why signals don't have this problem

Change the repro to use a signal, and keep the late write:

status = signal('Loading');
ngAfterViewInit() { this.status.set('Ready'); }

No error, with Eager, with OnPush, and even with the exhaustive check on. The page shows "Ready". The signal write marks the view as needing another refresh, and Angular renders it again before the tick finishes. A plain field can't do that, because Angular has no way to know it changed.

This is why NG0100 shows up so much less in signal-based code. It isn't that the check got weaker. Signals tell Angular when they change, so the view never ends up out of date.

6. The fix

Fix 1: make the value a signal

If you can't move the write yet, this is the smallest change that's actually correct. Change status = 'Loading' to status = signal('Loading'), read it as status() in the template, and use .set() wherever you assign it. As shown above, it removes the error and the stale view.

Fix 2: let the parent own the state

Most real cases come from a parent reaching into a child, or a child reaching into a parent. Make the parent the owner, and pass state down with input() or model():

import { Component, model, signal } from '@angular/core';

@Component({
  selector: 'app-child',
  template: `<button (click)="status.set('Ready')">Mark ready</button>`,
})
export class ChildComponent {
  status = model('Loading');
}

@Component({
  selector: 'app-root',
  imports: [ChildComponent],
  template: `
    <p>Status: {{ status() }}</p>
    <app-child [(status)]="status" />
  `,
})
export class App {
  status = signal('Loading');
}

The child changes state in an event handler, which runs outside a render, so there's no second-pass mismatch. If the child only needs to display the value, use status = input.required<string>() and bind it with [status]="status()". Don't bind [status] to a component that doesn't declare it as an input: with strictTemplates, that's a compile error.

Fix 3: load data with a resource, not a lifecycle hook

The most common real version of this bug is a "loading" flag flipped from a hook. Let a resource own that state instead. Resources are stable in v22:

import { Component } from '@angular/core';
import { httpResource } from '@angular/common/http';

@Component({
  selector: 'app-user',
  template: `
    @if (user.isLoading()) {
      <p>Loading…</p>
    } @else if (user.error()) {
      <p>Could not load the user.</p>
    } @else {
      <p>{{ user.value()?.name }}</p>
    }
  `,
})
export class UserComponent {
  user = httpResource<{ name: string }>(() => '/api/user');
}

You need provideHttpClient() in app.config.ts. I tested this with the exhaustive check enabled: it renders "Loading…", then the name once the request finishes, with no NG0100.

Fix 4: make bindings pure

A template binding should return the same thing every time it's read during the same render. If you need a random value or a timestamp, compute it once and store it in a field, or in a signal that a timer updates. Don't use a getter that calls Math.random() or Date.now().

Workarounds (they hide the bug, they don't fix it)

WorkaroundThe catch
this.cdr.detectChanges() right after the writeForces an extra synchronous render. It hides an ordering problem and can loop if you're not careful.
setTimeout(() => this.status = 'Ready')Pushes the write to a later task, so users see a flash of the old value. In a zoneless app with a plain field, nothing re-renders after the timeout, so the page can stay stale.

If you need one of these to ship, leave a TODO and a ticket pointing to Fix 1 or Fix 2.

7. Better design

  • The parent owns the state. Children get input() / model() and send changes back with output(). Don't use @ViewChild to write into a child, and don't read child fields in the parent's template.
  • Derive values with computed() instead of methods or getters in templates.
  • Use signals for anything a template reads. In an OnPush and zoneless app, a plain mutable field is a stale view waiting to happen.
  • Use httpResource() / resource() / rxResource(), or the async pipe, for async data. Don't use a loading flag set from ngAfterViewInit.

8. Preventing it

  • Turn on exhaustive checks in dev and tests. In app.config.ts:
import { isDevMode, provideCheckNoChangesConfig } from '@angular/core';

providers: [
  ...(isDevMode() ? [provideCheckNoChangesConfig({ exhaustive: true })] : []),
]

Add the same provider to TestBed.configureTestingModule in your specs. Without it, OnPush components can hide exactly the bugs this post is about.

  • Run component tests in CI. A TestBed spec that calls fixture.detectChanges() runs the same dev-mode check and fails with NG0100. A production build alone won't catch it.
  • Lint templates. @angular-eslint/template/no-call-expression flags function calls in bindings. There's no lint rule for "don't write to a @ViewChild in ngAfterViewInit", so catch that in code review.
  • Keep strict and strictTemplates on in tsconfig.json. That's what catches bindings to inputs that don't exist.
  • After upgrading to v22, treat every Eager the migration added as a to-do. Before switching a component to OnPush, move its template state to signals, or it may go quietly stale.

9. Takeaways

  • NG0100 means a binding returned a different value on Angular's dev-mode second pass: something changed state in the middle of a render.
  • It only throws in dev mode. In production the page just shows the old value.
  • The stack trace points at the template. The cause is the hook, the child, or the unstable getter that changed the value.
  • On Angular 22, OnPush is the default, and the normal check skips clean OnPush views. No error doesn't mean no bug. Turn on provideCheckNoChangesConfig({ exhaustive: true }) in dev and tests.
  • detectChanges() and setTimeout hide the problem. Signals, and state owned by the parent, actually fix it.
angularangular-errorsExpressionChangedAfterItHasBeenCheckedError

BKG

Engineer and writer behind CODELZ. I read the stack trace, reproduce the bug, and explain why it happens, not just how to silence it. Plus honest reviews of the books and tools worth your time.

Comments