This walks you through Angular's functional resolver pattern for pre-fetching data before route activation, which is the modern approach as of Angular 21. You get the ResolveFn syntax with inject() for services, handling route params, error catching with RxJS, and how to consume resolved data in components using both snapshot access and the newer input binding approach. The multiple resolver example is solid for real-world dashboards where you need several data sources ready before render. If you're still using class-based resolvers or loading data in ngOnInit, this shows the cleaner current style that reduces loading flicker and simplifies component logic.

skills.sh installs
179
GitHub stars
7
last updated
Aug 21, 2026

Install

$ npx -y skills add oguzhan18/angular-ecosystem-skills --skill angular-resolvers --agent claude-code

Installs into .claude/skills of the current project.

Files

Angular Route Resolvers

Version: Angular 21 (2025) Tags: Resolvers, Routing, Data Loading

References: Resolvers Guide

Best Practices

  • Create functional resolver
export const userResolver: ResolveFn<User> = (route, state) => {
  const userService = inject(UserService);
  const userId = route.paramMap.get('id');
  return userService.getUser(userId!);
};
  • Use resolver in route
const routes: Routes = [
  {
    path: 'user/:id',
    resolve: { user: userResolver },
    component: UserComponent
  }
];
  • Get resolved data in component
@Component({})
export class UserComponent {
  private route = inject(ActivatedRoute);
  
  user = this.route.snapshot.data['user'];
  
  // Or with input binding (Angular 17+)
  userId = input<string>();
}
  • Handle resolver errors
export const dataResolver: ResolveFn<Data> = (route, state) => {
  const service = inject(DataService);
  return service.getData().pipe(
    catchError(() => of(null))
  );
};
  • Use multiple resolvers

Sponsors

Details

Repository
github.com/oguzhan18/angular-ecosystem-skills
Category
Frontend Development
First seen
Jun 3, 2026

More from oguzhan18/angular-ecosystem-skills

All 45
1oguzhan18 avatarangular-deferrableoguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular Deferrable Views, @defer, lazy loading components, or deferred loading in Angular.178skills.sh installs
2oguzhan18 avatarangular-resourceoguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular Resource, Angular 19 resource API, or new async data loading with signals.178skills.sh installs
3oguzhan18 avatarangular-directivesoguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular Directives, custom directives, attribute directives, structural directives, or directive composition in Angular application176skills.sh installs
4sickn33 avatarreact-flow-architectsickn33/antigravity-awesome-skillsreact flow architect176skills.sh installs
5oguzhan18 avatarangular-routeroguzhan18/angular-ecosystem-skillsALWAYS use when working with Angular Router, routing configuration, guards, resolvers, lazy loading, or navigation in Angular applications.172skills.sh installs
6tuziapi avatartuzi-markdown-to-htmltuziapi/tuzi-skills将 Markdown 转换为带样式的 HTML,支持微信公众号兼容主题。支持代码高亮、数学公式、PlantUML、脚注、提示框和信息图。当用户要求 "markdown to html"、"md转html"、"转换为html" 时使用。164skills.sh installs