Signals: Angular 22 practice questions

Signals is 12% of the free Angular 22 mock (6 of 50 questions). Pick an answer to see right away whether it is correct, with the explanation and the documentation section it comes from.

NG.II · Angular 22 practice question

A developer is building a bidirectional temperature slider where the internal state is held in a Celsius signal. They use `linkedSignal` to derive the Fahrenheit display, ensuring that changing the Fahrenheit value automatically updates the underlying Celsius value. What is the primary mechanism that allows the Fahrenheit setter to modify the source Celsius signal?

const tempC = signal(0);
const tempF = linkedSignal(() => (tempC() * 9) / 5 + 32, {
  set: (valF) => tempC.set(((valF - 32) * 5) / 9),
});
Choose one answer
Check answer and explanation

Correct answer: The `linkedSignal` automatically subscribes to the setter function, which then uses `tempC.set()` to trigger a cascade update.

Explanation

The correct behavior involves the setter passed to `linkedSignal` executing the necessary logic to modify the source signal, which subsequently prompts the derived signal to recalculate, thereby satisfying the condition that 'Setting Fahrenheit updates Celsius, which reactively updates Fahrenheit.'

Common trap

The suggestion that the setter must invoke `tempC.update()` is misleading because the source code illustrates using `set()` for direct value assignment. Furthermore, the claim that `linkedSignal` bypasses standard signal mutation protocols is inaccurate.

Source: Angular docs: Dependent state with `linkedSignal` — Writing back to a source signal
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is building a component that fetches user data using an Angular Resource. If the component's view needs to show a 'Retry' button, which resource status should they check to determine if the data fetching process has failed?

Choose one answer
Check answer and explanation

Correct answer: The status is 'error', indicating the loader encountered a problem.

Explanation

The status is 'error', indicating the loader encountered a problem.

Common trap

Checking for 'loading' would only indicate an ongoing request, not a failure. 'idle' means no request was initiated.

Source: Angular docs: Async reactivity with resources — Resource status
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is building a component that needs to display real-time updates from a live data feed, like a WebSocket connection. They are using Angular's resource functionality. Which approach should they employ to ensure the signal automatically reflects every incoming data packet?

const liveData = signal(null);

const feedResource = resource({
  stream: () => liveData,
});
Choose one answer
Check answer and explanation

Correct answer: Use `resource` with a `stream` provider, as this signal will continuously update as new data arrives.

Explanation

The appropriate approach is to 'Use `resource` with a `stream` provider, as this signal will continuously update as new data arrives.' This is because the official documentation indicates that the `stream` mechanism is intended for data sources that provide ongoing updates.

Common trap

The suggestion to 'Use `loader` because it is designed to handle continuous data streams over time' is flawed because the documentation explicitly states that `loader` resolves only once per request, making it inappropriate for persistent updates. Furthermore, the idea to 'Use a standard `signal` and manually subscribe to the data source outside of the resource context' circumvents the resource management pattern that is intended for this scenario.

Source: Angular docs: Async reactivity with resources — Streaming resources
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is building a data flow where a subsequent data fetch relies on an ID obtained from a preceding data service. If they use `resource.value()` directly within the `params` function of the downstream resource, what is the primary consequence according to best practices?

const upstreamResource = resource({ /* ... */ });
const downstreamResource = resource({
  params: () => {
    const id = upstreamResource.value(); // Direct read
    return id ? { itemId: id } : undefined;
  },
  loader: ({params}) => fetchDetail(params.itemId),
});
Choose one answer
Check answer and explanation

Correct answer: The downstream resource will incorrectly remain in an 'idle' state even if the upstream resource has successfully loaded data.

Explanation

The correct outcome is that returning `undefined` from `params` causes the resource to enter an 'idle' state instead of accurately reflecting the upstream resource's status.

Common trap

The scenario where the downstream resource immediately throws an error because reading `.value()` outside of a computed context is disallowed is incorrect because the API permits direct reading, but the resulting behavior is flawed; the situation where the downstream resource pauses indefinitely until the upstream resource emits a specific 'ready' signal describes a state management issue not addressed by this particular pattern.

Source: Angular docs: Async reactivity with resources — Chaining vs. reading resource values directly
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is creating an `effect` that must execute only when a user profile signal changes, even if another unrelated counter signal is read inside the effect's body. To ensure the counter's updates do not trigger the effect, what approach should be used when accessing the counter signal?

effect(() => {
  const user = currentUser();
  console.log(`User: ${user} and Counter: ${untracked(counter())}`);
});
Choose one answer
Check answer and explanation

Correct answer: Wrap the counter signal access within `untracked()` to prevent dependency tracking.

Explanation

The recommended method is to 'Wrap the counter signal access within `untracked()` to prevent dependency tracking,' because this explicitly instructs Angular not to register the read as a dependency for triggering the effect.

Common trap

The suggestion to 'Use `computed(() => counter())` inside the effect to isolate the reading' is flawed because `computed` is designed for deriving values, not for selectively disabling dependency tracking within an active effect.

Source: Angular docs: guide/signals/overview — Reading without tracking dependencies
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is implementing a complex side effect using `afterRenderEffect`. They need to ensure that subsequent phases correctly receive the output from the preceding phase's callback. Which characteristic of the effect execution flow must they rely on?

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

const dataSignal = signal(1);

afterRenderEffect(() => {
  // Phase 1
  const result1 = dataSignal();
  return result1 * 2; // This return value feeds the next phase
});
Choose one answer
Check answer and explanation

Correct answer: The return value of a phase's callback is automatically passed as a Signal input to the next phase's callback.

Explanation

The mechanism where a phase's callback output automatically feeds into the subsequent phase's Signal input is the correct description of how the effect phases operate sequentially.

Common trap

The assertion that only the `earlyRead` phase can yield a value affecting later execution stages is inaccurate, as the documentation clarifies that `earlyRead` only receives the cleanup function, not a return value that dictates subsequent phase behavior.

Source: Angular docs: Effects — Render phases
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is implementing a custom DOM manipulation routine that requires reading the current element dimensions immediately before applying a calculated style change. To ensure the most efficient execution order and avoid layout thrashing, which phase of `afterRenderEffect` should be utilized for this operation?

afterRenderEffect({ 
  earlyRead: () => { /* ... */ }, 
  write: () => { /* ... */ }, 
  mixedReadWrite: () => { /* ... */ }, 
  read: () => { /* ... */ } 
});
Choose one answer
Check answer and explanation

Correct answer: The `earlyRead` phase, as it allows reading the DOM before subsequent write callbacks.

Explanation

The `earlyRead` phase is explicitly designed for reading from the DOM before a subsequent write callback, which matches the requirement for reading dimensions before applying a style change.

Common trap

The `mixedReadWrite` phase is tempting because it allows both reading and writing, but the documentation warns against using it if the work can be separated for optimization. The `read` phase is incorrect because it explicitly forbids writing to the DOM.

Source: Angular docs: Effects — Render phases
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is implementing a data-fetching mechanism using Angular's `resource` function and needs to ensure the initial server-rendered HTML correctly reflects the loaded data during subsequent client-side hydration. What is the primary requirement for the `id` property when configuring this resource?

const userResource = resource({
  params: () => ({id: userId()}),
  loader: ({params}) => fetchUser(params),
  id: 'user-unique-id',
});
Choose one answer
Check answer and explanation

Correct answer: The provided `id` must be unique across the entire application and must match exactly between the server and client execution contexts.

Explanation

The specification mandates that the identifier must possess uniqueness throughout the application and maintain exact consistency between the server and client execution environments to allow Angular to correctly associate the cached entry with the requesting resource.

Common trap

Assigning the identifier to be dependent on the current user session undermines the objective of caching the server's output, and excluding the identifier prevents the state transfer mechanism from functioning.

Source: Angular docs: Async reactivity with resources — Caching `resource` data with SSR
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is implementing a data fetching mechanism using Angular's resource loading pattern. If the input signal driving the resource's parameters changes while the underlying network request is in flight, what is the expected behavior regarding the ongoing fetch operation?

const userId: Signal<string> = getUserId();

const userResource = resource({
  params: () => ({id: userId()}),
  loader: ({params, abortSignal}): Promise<User> => {
    return fetch(`users/${params.id}`, {signal: abortSignal}).then((res) => res.json());
  },
});
Choose one answer
Check answer and explanation

Correct answer: The resource automatically cancels the existing HTTP call, initiating a fresh request with the new parameters.

Explanation

When the parameters used by a resource change while it is in the process of loading, the intended behavior is for the resource to terminate the current, outstanding loading operation and start a new request using the updated parameters. This functionality is enabled by supplying an `abortSignal` to the underlying fetch mechanism.

Common trap

A scenario where the existing request completes even after parameter modifications, causing the new parameters to be disregarded, represents an inefficient situation prone to race conditions. Furthermore, suggesting that the resource immediately throws a synchronous error upon detecting a parameter shift is inconsistent with the established design pattern for resource loading cancellation.

Source: Angular docs: Async reactivity with resources — Aborting requests
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is implementing a state management pattern where a derived signal must maintain a user's selection even if the underlying list of options changes. Which approach correctly utilizes `linkedSignal` to achieve this preservation logic?

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

@Component({
  selector: 'app-picker',
  standalone: true,
  template: '<!-- Template logic here -->'
})
export class PickerComponent {
  shippingOptions = signal([{id: 0, name: 'Ground'}, {id: 1, name: 'Air'}] as {id: number, name: string}[]);

  selectedOption = linkedSignal<{id: number, name: string}, {id: number, name: string}>({
    source: this.shippingOptions,
    computation: (newOptions, previous) => {
      if (previous?.value) {
        return newOptions.find(opt => opt.id === previous.value.id) ?? newOptions[0];
      }
      return newOptions[0];
    },
  });
}
Choose one answer
Check answer and explanation

Correct answer: Defining the `linkedSignal` with a separate `source` and `computation` allows the function to access the previous state of the derived signal via the `previous` argument.

Explanation

The correct approach involves setting up the `linkedSignal` by providing distinct definitions for the `source` and the `computation`. This design enables the function to retrieve the prior state of the derived signal through the `previous` argument.

Common trap

The suggestion that the `linkedSignal` maintains its prior value without the `source` signal changing, thereby bypassing the `computation` function, is flawed. Furthermore, the claim that the `computation` function only receives the new `source` value, precluding a comparison with the prior selection, is inaccurate because the `previous` object furnishes access to the former linked signal value.

Source: Angular docs: Dependent state with `linkedSignal` — Accounting for previous state
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer implements a `computed` signal that relies on another signal. If the dependency signal updates, which mechanism ensures the computed signal's value is recalculated?

Choose one answer
Check answer and explanation

Correct answer: Angular automatically establishes a 'live' connection, causing the computed signal to re-evaluate.

Explanation

The accurate statement is that Angular automatically establishes a 'live' connection, causing the computed signal to re-evaluate. This is because the evaluation of a `computed` signal initiates a reactive context within Angular, thereby setting up dependency tracking.

Common trap

The suggestion that the developer must manually call a `.trigger()` method on the computed signal after the dependency changes is misleading, as the system manages dependency tracking automatically. Furthermore, the assertion that the computed signal only updates when the component hosting it is re-rendered by the view engine is incorrect, as template rendering is just one of several contexts that trigger reactivity.

Source: Angular docs: guide/signals/overview — Reactive contexts
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer implements a custom resource loader for an asynchronous data fetch. If the initial parameters passed to the loader function result in a return value of `undefined`, what is the resulting status of the resource according to the framework's logic?

const loader = (params: ResourceLoaderParams) => {
  if (!params.dataConfig) {
    return undefined;
  }
  // ... actual loading logic
};
Choose one answer
Check answer and explanation

Correct answer: The resource status will immediately transition to 'idle' because the loader function was not executed.

Explanation

The resource status will immediately transition to 'idle' because the loader function was not executed.

Common trap

The suggestion that the resource status will remain in its previous state until a subsequent successful call is made is incorrect; the source specifies the transition to 'idle' when the parameter computation yields undefined. Furthermore, the idea that the resource status will transition to 'pending' because the loader is considered to be in the process of initializing is also wrong, as the loader never runs.

Source: Angular docs: Async reactivity with resources — Resource loaders
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer implements an `effect` in a component to log the current value of a user status signal whenever it changes. What is guaranteed about the execution of this effect?

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

const status = signal('idle');

effect(() => {
  console.log(`Status is: ${status()}`);
});
Choose one answer
Check answer and explanation

Correct answer: The effect is guaranteed to run at least once upon initialization, and subsequently whenever any dependency signal changes.

Explanation

The correct statement is that the effect is guaranteed to run at least once upon initialization, and subsequently whenever any dependency signal changes. This accurately describes the inherent behavior of effects.

Common trap

The statement claiming the effect will only execute if the signal is explicitly updated via a setter function is incorrect because effects monitor signal reads, not solely setter invocations. Furthermore, the assertion that the effect will only run asynchronously if the change detection cycle is manually triggered is wrong, as effects execute asynchronously by default during the change detection process.

Source: Angular docs: Effects — Effects
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer implements a service that uses `effect()` to log changes to a global configuration signal. This service is provided at the root level of the application. When the application starts and change detection begins, when will this logging effect execute relative to the rendering of any component?

import { Injectable, signal, effect } from '@angular/core';
@Injectable({ providedIn: 'root' }) 
export class ConfigService {
  config = signal({ theme: 'dark' });
  
  constructor() {
    effect(() => {
      console.log('Config changed:', this.config());
    });
  }
}
Choose one answer
Check answer and explanation

Correct answer: It will execute before any component is checked during the change detection process.

Explanation

An effect established within a service provided at the root level is categorized as a Root Effect, meaning it runs before the change detection process examines any component.

Common trap

The description stating that the effect runs immediately following the completion of Angular's change detection cycle for all components actually describes the behavior of a View Effect, which executes before its associated component is checked.

Source: Angular docs: Effects — Execution of effects
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is integrating a complex third-party charting library into an Angular component. This library requires direct access to the rendered DOM element to initialize and update its visualization after Angular has applied its structural changes. Which Angular signal API should the developer use to ensure the chart updates correctly after the view has been committed?

afterRenderEffect(() => {
  // Logic to call chart.updateData(data) using the DOM element
});
Choose one answer
Check answer and explanation

Correct answer: afterRenderEffect(() => { /* DOM manipulation logic */ });

Explanation

The developer must use 'afterRenderEffect' because it guarantees the code runs after Angular has finished committing changes to the DOM, which is necessary for interacting with external libraries that need a fully rendered view.

Common trap

Using 'effect' would execute before Angular updates the DOM, meaning the DOM element might not yet be available or stable for the third-party library. While 'MutationObserver' can watch for changes, it is not the correct mechanism for reacting to a specific rendering lifecycle event.

Source: Angular docs: Effects — Side effects on DOM elements
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is managing an `Order` object within a parent signal. They use `linkedSignal` to create a derived signal for the `shippingMethod`. If they call `shippingMethod.set('Overnight')`, what must the implementation of the `set` function ensure to correctly update the parent signal?

interface Order {
  id: number;
  shippingMethod: string;
}

const order = signal<Order>({ id: 42, shippingMethod: 'Ground' });

const shippingMethod = linkedSignal(() => order().shippingMethod, {
  set: (newMethod) => {
    // Implementation goes here
  },
});
Choose one answer
Check answer and explanation

Correct answer: It must use `order.update((currentOrder) => ({ ...currentOrder, shippingMethod: newMethod }))` to create an immutable copy.

Explanation

The recommended pattern involves employing `order.update` alongside the spread operator to guarantee that the parent object is modified in an immutable fashion.

Common trap

Directly altering the existing object reference violates the tenets of signal state management, and replacing the entire object is less targeted than modifying only the required field.

Source: Angular docs: Dependent state with `linkedSignal` — Updating a property inside a parent object
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A state management service exposes a signal derived from an internal writable signal using `.asReadonly()`. A component then attempts to call `.set()` on the exposed signal. What will be the result?

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

class StateService {
  private _data = signal([1, 2]);
  public data = this._data.asReadonly();
}

// In component:
const service = new StateService();
service.data.set([3, 4]); // Attempt to modify
Choose one answer
Check answer and explanation

Correct answer: The modification will fail silently because the readonly wrapper prevents direct mutation methods like .set() or .update().

Explanation

The modification will fail silently because the readonly wrapper prevents direct mutation methods like .set() or .update().

Common trap

The assertion that 'the modification will succeed because the signal object itself is mutable' is misleading, as the readonly wrapper enforces immutability on the API exposed.

Source: Angular docs: guide/signals/overview — Writable signals
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer uses an `OnPush` component and displays a value derived from a signal directly in the template. If the signal's value changes, what is the resulting behavior concerning the component's rendering cycle?

<div *ngIf="signalValue() > 10">Data is high</div>
Choose one answer
Check answer and explanation

Correct answer: Angular automatically triggers a change detection cycle specifically for this component to reflect the new signal value.

Explanation

When a signal is accessed within the template of a component configured with `OnPush`, Angular automatically registers this access as a dependency, leading to the component updating when the signal's value changes.

Common trap

Suggesting that manual invocation of change detection is necessary contradicts the inherent automatic dependency tracking provided by signals; asserting that signal reading has no impact on rendering is inaccurate because dependency tracking is established.

Source: Angular docs: guide/signals/overview — Reading signals in `OnPush` components
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is using an `effect` hook in a component to fetch user data asynchronously. If they read a signal inside the asynchronous block (after `await`), what will happen to the signal's dependency tracking?

effect(async () => {
  await apiService.fetchUser();
  console.log(userSignal());
});
Choose one answer
Check answer and explanation

Correct answer: The signal read will not be tracked because the reactive context is lost after the `await` operation.

Explanation

The signal read will not be tracked because the reactive context is lost after the `await` operation.

Common trap

The assertion that 'the signal read will still be tracked, as effects maintain reactivity across async boundaries' is incorrect because the reactive context is strictly synchronous; furthermore, the claim that 'the effect will automatically re-run whenever the signal changes, regardless of where it is read' is misleading as reactivity depends on tracking, not just re-running.

Source: Angular docs: guide/signals/overview — Reactive context and async operations
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is using `linkedSignal` to derive a derived state from a source signal containing complex objects. They configure a custom equality check to only compare the `userId` property. What is the primary effect of providing this custom equality function?

const source = signal({ userId: 42, data: [1, 2] });
const derived = linkedSignal(() => source(), { equal: (a, b) => a.userId === b.userId });
Choose one answer
Check answer and explanation

Correct answer: The derived signal will only trigger updates downstream if the comparison function determines the new value is not equivalent to the previous one based on the custom logic.

Explanation

The derived signal will only trigger updates downstream if the comparison function determines the new value is not equivalent to the previous one based on the custom logic.

Common trap

The statement that 'the derived signal will only update if the entire object structure changes, even if the `userId` remains constant' describes the default behavior of signals without custom equality, while the assertion that 'the custom equality function overrides the signal's internal change detection mechanism completely, making it immune to Angular's standard change detection cycle' is incorrect.

Source: Angular docs: Dependent state with `linkedSignal` — Custom equality comparison
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is using the `resource` API to fetch user data. They want to access the current loading state, whether the data has arrived, or any errors encountered during the fetch operation, without subscribing to the resource itself. Which property should they use?

const userResource = resource({
  params: () => ({id: userId()}),
  loader: ({params}) => fetchUser(params),
});

const snapshot = userResource.snapshot;
Choose one answer
Check answer and explanation

Correct answer: The `snapshot` property, which yields a signal encapsulating the resource's current status, value, or error.

Explanation

The appropriate mechanism is 'The `snapshot` property, which yields a signal encapsulating the resource's current status, value, or error.' This is because the official documentation mandates that every resource possesses a `snapshot` property that delivers a signal reflecting its present condition, which encompasses status, value, or error.

Common trap

The '`state` property, which directly exposes a reactive object containing the loading status and result' is misleading because, despite suggesting state management, it is not the designated API for this function. Furthermore, the '`currentValue()` method, which must be called on the resource instance to retrieve the latest data' is incorrect because the source material indicates that the snapshot is a signal, not a method call.

Source: Angular docs: Async reactivity with resources — Resource composition with snapshots
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


NG.II · Angular 22 practice question

A developer is using a `signal` to hold an array of user objects. They want the signal to only update its consumers if the actual contents of the array have changed, even if a new array instance is provided. Which configuration should they apply when initializing the signal?

const userList = signal([], { equal: deepObjectComparer });
Choose one answer
Check answer and explanation

Correct answer: Provide a custom equality function, such as one implementing deep comparison.

Explanation

Defining a custom equality function empowers the developer to specify the exact criteria for equality, which is necessary when performing deep comparisons on intricate data structures such as arrays.

Common trap

Assuming that signals inherently conduct deep checks for complex data types is flawed, as signals default to checking for reference equality. Furthermore, attempting to utilize the 'byValue' parameter during signal instantiation is incorrect because that API parameter does not exist.

Source: Angular docs: guide/signals/overview — Signal equality functions
Checked against the cited text on 2026-11-25.

Report an error in this question

Open this question on its own page


Back to all topics