Claude-skill-registry angular-router
Angular Router for navigation, routing configuration, route guards, lazy loading, and parameter handling. Use when setting up routes, implementing navigation guards, lazy loading modules, handling route parameters, or implementing breadcrumbs and nested routes in Angular applications.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/angular-router" ~/.claude/skills/majiayu000-claude-skill-registry-angular-router && rm -rf "$T"
manifest:
skills/data/angular-router/SKILL.mdsource content
Angular Router Skill
Rules
Router Configuration
- Use
inprovideRouter(routes)
for standalone applicationsapp.config.ts - Define routes in a separate
fileroutes.ts - Use
for empty path redirectspathMatch: 'full' - Include wildcard route (
) as the LAST route for 404 handling**
Lazy Loading
- Use
for lazy loading feature routesloadChildren - Use
for lazy loading standalone componentsloadComponent - Do NOT eagerly import feature modules in route configuration
Route Guards
- Use functional guards with
for dependency injectioninject() - Return
orboolean
from guardsUrlTree - Use
for guard redirectsrouter.createUrlTree(['/path']) - Do NOT use class-based guards (CanActivate, CanDeactivate interfaces)
Route Parameters
- Use
to access route parameterstoSignal(route.params, { initialValue }) - Use
to access query parameterstoSignal(route.queryParams, { initialValue }) - Provide
when converting route observables to signalsinitialValue - Do NOT manually subscribe to
orroute.paramsroute.queryParams
Navigation
- Use
for programmatic navigationrouter.navigate(['/path']) - Use
for template navigation[routerLink]="['/path']" - Do NOT manipulate URLs directly via
window.location
Context
When to Use This Skill
Activate this skill when you need to:
- Configure application routes
- Implement route guards (CanActivate, CanDeactivate, Resolve)
- Set up lazy loading for feature modules
- Handle route parameters and query parameters
- Implement nested and child routes
- Create navigation menus and breadcrumbs
- Handle route transitions and animations
- Implement route redirects and wildcards
- Work with router events and navigation lifecycle
Basic Setup
// app.routes.ts import { Routes } from '@angular/router'; export const routes: Routes = [ { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: 'home', component: HomeComponent }, { path: 'about', component: AboutComponent }, { path: '**', component: NotFoundComponent } ]; // app.config.ts import { ApplicationConfig } from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; export const appConfig: ApplicationConfig = { providers: [ provideRouter(routes) ] };
Lazy Loading
// Feature module lazy loading export const routes: Routes = [ { path: 'admin', loadChildren: () => import('./admin/admin.routes') .then(m => m.ADMIN_ROUTES) }, { path: 'workspace', loadComponent: () => import('./workspace/workspace.component') .then(m => m.WorkspaceComponent) } ];
Route Guards
// Auth guard import { inject } from '@angular/core'; import { Router } from '@angular/router'; import { AuthService } from './auth.service'; export const authGuard = () => { const authService = inject(AuthService); const router = inject(Router); if (authService.isAuthenticated()) { return true; } return router.createUrlTree(['/login']); }; // Apply guard { path: 'dashboard', component: DashboardComponent, canActivate: [authGuard] }
Route Parameters
// Route with parameter { path: 'user/:id', component: UserDetailComponent } // Access in component export class UserDetailComponent { private route = inject(ActivatedRoute); userId = toSignal( this.route.params.pipe(map(params => params['id'])), { initialValue: null } ); }