Ch. 4 · Angular

Angular OnPush and Input Reference Changes

Angular OnPush and Input Reference Changes. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readbeginnerupdated Oct 3, 2026

OnPush reduces unnecessary checking but does not mean a component updates only once. Input changes, events and relevant reactive notifications can make it eligible for checking.

Before you start

You should understand a component’s class, template and dependencies. Follow both the framework lifecycle and the ownership of each value or resource. Apply examples inside an Angular application; the surrounding application configuration and imports depend on the feature being demonstrated.

The practical goal is to reason through this situation: Replacing an input object makes a new value visible to a child; mutating the same object can obscure the change. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.

Step-by-step walkthrough

Step 1: Trace the input

A parent and child may share one object. Changing a field does not necessarily supply a new input reference.

Step 2: Replace the value

Create a new object for the edited input. This clearly communicates a changed value across the component boundary.

Step 3: Inspect other notifications

Events and relevant reactive changes also affect checking. OnPush is not a promise that components update only once.

Worked scenario

Replacing an input object makes a new value visible to a child; mutating the same object can obscure the change.

For a user input, replace user with { ...user, name: 'Ada' } instead of modifying user.name in place. Then inspect the child display. If it is still stale, verify the actual binding and reactive notification path rather than adding arbitrary manual checks across the tree.

Common mistake

Assuming every mutation automatically triggers the correct subtree produces stale interfaces.

Verify the behavior

Test replacement and mutation separately, including updates originating outside the child. Verify the changed field reaches the template.

Interview exercise

Fix a stale child display.

Answer and reasoning

Use immutable input updates or an appropriate reactive notification, then inspect whether the component is being checked.

Continue learning

Compare the scenario with the Angular interview questions and test your understanding with the Angular MCQs. For terminology and implementation details, consult the reference material.

More in Angular

read ✓Angular · mid

Angular Defer Blocks and Lazy Rendering

Load template regions on demand with @defer, choose a trigger, and use placeholders without delaying critical content.

~2 min readread →
read ✓Angular · hard

Angular Global Error Handling

Catch uncaught errors with a custom ErrorHandler, distinguish client from HTTP errors, and surface safe messages to users.

~2 min readread →
read ✓Angular · mid

Angular Host Directives and Composition

Attach behavior to elements with attribute directives, bind to the host with the host property, and compose directives with hostDirectives.

~2 min readread →
esc