angular-routing

Configure Angular v20+ routing with lazy loading, functional guards, resolvers, and signal-based route parameters.

Updated Aug 10, 2025
One-click install
npx skills add https://github.com/afonsoft/ai-studio-workspace --skill angular-routing-afonsoft
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: angular-routing
Source: https://github.com/afonsoft/ai-studio-workspace/tree/main/agents/skills/angular-routing
Command: npx skills add https://github.com/afonsoft/ai-studio-workspace --skill angular-routing-afonsoft

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Setting up navigation in modern Angular applications involves many moving parts: lazy loading, authentication guards, route parameters, resolvers, and nested routes. This Skill provides ready-to-use patterns for Angular v20+ routing so you avoid misconfigured routes, boilerplate errors, and outdated class-based guard syntax. ## Core Features & Use Cases - Route Configuration: Set up routes with provideRouter, redirects, wildcards, and lazy loading via loadComponent and loadChildren. - Functional Guards & Resolvers: Implement auth guards, role guards, canDeactivate guards, and data resolvers using modern functional APIs with inject(). - Signal-Based Route Parameters: Bind route and query parameters directly to component inputs using withComponentInputBinding and input.required. - Use Case: You need to protect an admin dashboard so only authenticated users with the admin role can access it, while lazy loading the admin feature. Use this Skill to generate the authGuard, roleGuard, and lazy-loaded route configuration. ## Quick Start Set up Angular routing for my app with a lazy-loaded admin section protected by an authentication guard and a user detail page that reads the id route parameter as a signal input.

Frequently Asked Questions about angular-routing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I lazy load routes in Angular?▼

Use loadChildren to lazy load an entire feature's route file or loadComponent for a single component. Both accept a dynamic import, for example loadComponent: () => import('./settings/settings.component').then(m => m.Settings), so the code loads only when the route is visited.

How do I create an auth guard in Angular with functional guards?▼

Define a CanActivateFn that uses inject() to access your auth service and Router. Return true when authenticated, otherwise return router.createUrlTree(['/login']) with the attempted URL as a returnUrl query parameter, then attach it via canActivate: [authGuard].

How do I read route parameters as signals in Angular?▼

Enable withComponentInputBinding() in provideRouter, then declare route params as component inputs such as id = input.required<string>(). Angular automatically binds the :id route parameter and query parameters to matching input properties.

Does Angular routing support preloading lazy modules?▼

Yes, use withPreloading(PreloadAllModules) in provideRouter to preload all lazy routes, or implement a custom PreloadingStrategy to preload selectively based on route data flags or network conditions like saveData and connection speed.

How do I prevent navigation away from a form with unsaved changes in Angular?▼

Implement a CanDeactivateFn guard that checks a canDeactivate() method on the component, typically returning whether the form is pristine. Attach it to the route with canDeactivate: [unsavedChangesGuard] and show a confirmation dialog when changes exist.