← Zurück zu Ada
AgentAda
Angular-Routing und URL-Zustand
Hält Navigation, Datensatzkennungen und Filter mit neu ladbaren und teilbaren Browser-URLs synchron.
angular-router
Entdecke, wie der Skill hilftWann ist der Skill hilfreich?
Nutze diesen Skill, wenn Zurücknavigation oder geänderte Kennungen veraltete Inhalte anzeigen.
Wobei hilft er dir?
- Reagiert auf Parameteränderungen auch bei wiederverwendeten Komponenten.
- Speichert passende Filter-, Seiten- und Tabzustände in URL-Parametern.
- Behandelt verzögert geladene Routen und ungespeicherte Eingaben neben serverseitigen Rechten.
Das könntest du fragen
Korrigiere unsere Kundenliste für geteilte Filterlinks, Vorwärts- und Zurücknavigation sowie wechselnde Kundenkennungen. Öffne einen gefilterten Link in einem neuen Tab und wechsle zwischen zwei Kunden. URL, aktiver Filter und angezeigter Datensatz müssen zusammenpassen.
Ausführliche Dokumentation
Hier findest du die ursprüngliche Anleitung, Beispiele und Prüfschritte des Skills in ihrer Originalsprache.
Weniger anzeigen
Angular Router & URL State
Keep navigation, route parameters, query filters and lazy-loaded feature boundaries synchronized with the browser URL so deep links, reloads and Back/Forward navigation work reliably.
1. Route configuration and lazy loading
- Organize routes along feature boundaries using
loadComponentandloadChildrenso heavy feature bundles load on demand. - Place feature-scoped services and stores in the route's
providers: [...]array when their lifetime should match that route subtree. - Check whether
withComponentInputBinding()is enabled inprovideRouter(...): when enabled, route params, path data and query params bind directly to component@Input()/input()properties; otherwise, read them reactively fromActivatedRoute.
2. Reacting to same-component route and query parameter changes
- Angular reuses the same component instance when only route params (
:id) or query params (?page=2&q=foo) change on the same route configuration. - Never read
route.snapshot.paramMaporroute.snapshot.queryParamMaponly once inngOnInitwhen the user can navigate between items or filter states on the same route; subscribe toroute.paramMap/route.queryParamMap(withswitchMapto cancel stale loads) or usewithComponentInputBinding()signal inputs. - Update URL filter/pagination/tab state with
router.navigate([], { relativeTo: route, queryParams, queryParamsHandling: 'merge' })so refresh and link sharing preserve the user's view.
3. Guards, resolvers and scroll/focus restoration
- Prefer functional guards (
CanActivateFn,CanDeactivateFn,CanMatchFn) returning aboolean | UrlTree(orObservable/Promisethereof) in modern Angular, matching the project's existing guard style. - Use
CanDeactivateFnto protect unsaved form drafts from accidental navigation. - Treat client-side guards strictly as UX navigation flow: real authorization must always be enforced on the server.
Before you finish
- Same-component parameter and query changes reload data reactively via
paramMap/queryParamMapor route input bindings. - Direct URL entry, browser Back/Forward and page reload preserve expected state.
- Guards return
UrlTreeredirects cleanly and are never treated as a substitute for server authorization.
Enthaltene Dateien 2
LICENSE.txtSKILL.md
