October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Angular Route Data Resolvers: Configure, Use, and Handle Them

Angular resolvers fetch essential route data before activation. Learn how to configure ResolveFn, consume results, control reruns, handle failures, and decide when route resources fit better.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An Angular route data resolver fetches data during navigation, before the destination route activates. The component can therefore receive essential data as part of its initial route state—but navigation waits for the resolver to finish. Use a resolver when a page needs that data to activate coherently, not as a default for every request.

How a resolver works

A resolver is a function or class that supplies route data before activation. Angular runs it as part of navigation, then makes its result available under the key configured on the route. If resolution takes time, the destination does not activate until it completes.

That makes resolvers useful for essential route data, such as the record needed to render a detail page. Optional or below-the-fold content can instead load after activation so it does not hold up the entire route. See Angular’s Data resolvers guide.

Configure a functional resolver

For new code, Angular’s guide uses a function typed as ResolveFn<T>. The resolver receives route and router-state snapshots, can obtain dependencies with inject(), and may return data synchronously or asynchronously. It can also return a RedirectCommand.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { inject } from '@angular/core';
import { ResolveFn } from '@angular/router';

export const userResolver: ResolveFn<User> = (route) => {
  const userStore = inject(UserStore);
  const userId = route.paramMap.get('id')!;
  return userStore.getUser(userId);
};

Register the resolver in the route’s resolve map. The map’s property name becomes the key for the returned value:

import { Routes } from '@angular/router';

export const routes: Routes = [
  {
    path: 'users/:id',
    component: UserDetailComponent,
    resolve: { user: userResolver },
  },
];

Here, the resolved value is named user. In the routed component, read it from the activated route:

import { ActivatedRoute } from '@angular/router';

export class UserDetailComponent {
  private route = inject(ActivatedRoute);
  user = this.route.snapshot.data['user'] as User;
}

Angular’s guide also demonstrates signal-based access to resolved data. The class-based Resolve<T> interface remains documented for existing applications; the ResolveFn API describes the functional form.

Execution order and data dependencies

Guards run before resolvers. Angular waits for all guards to succeed before starting resolution. In a nested route tree, parent resolvers run before child resolvers, so a child resolver can use data resolved by its parent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not rely on the order of multiple resolver entries on the same route: Angular’s ResolveData API provides no ordering guarantee. If one result depends on another, put the dependency in a parent-child route relationship or combine the dependent work explicitly.

Choose when resolvers rerun

The default runGuardsAndResolvers policy is paramsChange. It reruns for path or route-parameter changes, but not for query-parameter changes. If the resolved data depends on a query parameter, select a policy that includes query parameters or provide a predicate. Other documented options include always and policies scoped to path parameters.

Set the policy according to the inputs that actually affect the returned data. For example, if changing a user ID changes the requested record, the default parameter behavior may be appropriate; if changing a filter in the query string changes the result, configure reruns accordingly. The available values and predicate form are documented in Angular’s Route API and RunGuardsAndResolvers API.

Handle resolver errors and redirects

A failed resolver can end navigation in a NavigationError. Choose where to handle failures based on whether the response is shared across the application or specific to one route:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Central policy: use withNavigationErrorHandler when the application should apply a common response to navigation errors.
  • Application-level event handling: listen for NavigationError router events when the app needs to show UI, offer retry behavior, or record navigation failures.
  • Route-specific recovery: catch an error in the resolver when that route has a meaningful local fallback or should redirect. Returning a RedirectCommand sends the current navigation elsewhere.

These approaches are covered in Angular’s resolver guide and lifecycle and events guide. Select one that matches the desired failure behavior rather than allowing an unhandled failure to leave the user without a clear outcome.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep navigation waits manageable

Because activation waits for required resolver data, a slow request can make navigation appear stalled. Keep resolver work focused on essentials, handle failures, and consider caching where it fits the data’s freshness requirements. A reasonable timeout can prevent an indefinite wait; these are design recommendations, not performance guarantees.

Where waiting is noticeable, provide navigation progress feedback. A resolver does not eliminate the wait—it places it before route activation. Angular discusses resolver behavior and navigation handling in its Data resolvers guide.

Resolver or route resource?

Choose based on the experience the route needs. A resolver gates activation until its data is ready. Angular route resources instead provide reactive loading and error status, and the resources guide says resource work across the matched route hierarchy runs concurrently.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Consideration Resolver Route resource
When the route can render After the resolved data is ready. Can render with reactive loading status while data loads.
Loading and error state Handled as part of navigation and its error handling. Exposed through reactive status, loading, and error signals.
Work across matched routes Parent resolvers run before child resolvers; same-route resolver order is not guaranteed. The resources guide describes work across the matched route hierarchy as concurrent.
Refreshing data Resolution generally runs again when navigation and the configured rerun policy call for it. Fetching is reactive to resource dependencies.

Use a resolver when essential data must be ready before activation. Consider a route resource when the interface should activate with reactive loading and error states. These approaches represent different navigation behavior, not a universal performance ranking. See Angular’s data fetching with resources guide.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.