← Ada adatlapja
AgentAda
Angular-komponensek és függőségek
Elválasztja a megjelenítést, vezérlést és szolgáltatásokat, egyértelmű hatókörrel és erőforrás-élettartammal.
angular-components-di
Nézd meg, miben segítMikor hasznos?
Akkor használd, ha túl nagy komponensek vagy többször létrejövő szolgáltatások zavarják az állapotkezelést.
Miben segít neked?
- Típusos bemeneteket és eseményeket tervez üzleti mellékhatások nélküli sablonokhoz.
- Tudatosan választ alkalmazás-, útvonal- vagy komponensszintű szolgáltatáspéldányt.
- Megszünteti a szükségtelen időzítőket, feliratkozásokat és eseményfigyelőket.
Például ezt kérheted
Bontsd fel a rendelési képernyőt, és mutasd meg, mely szolgáltatások éljenek tovább navigálás után. Lépj el egy nem mentett rendelésről, majd térj vissza. Ellenőrizd a szándékosan megőrzött piszkozatot és a megszűnt komponens eseményfigyelőinek felszabadítását.
Részletes dokumentáció
Itt a skill eredeti útmutatóját, példáit és ellenőrzési szempontjait olvashatod az eredeti nyelven.
Összecsukás
Angular Components & Dependency Injection
Keep components focused on presentation and user interaction, and organize services and providers with explicit boundaries, injector scopes and lifetimes.
1. Component boundaries and inputs/outputs
- Split smart/container components (which coordinate routes, services and state) from presentational components (which receive inputs and emit outputs).
- Match the project's input/output style (
input()/output()/model()in modern Angular, or@Input()/@Output()where standard); keep inputs immutable from the child's perspective. - Never put business side effects, HTTP calls or heavy computation inside template expressions or property getters called on every change-detection cycle; use
computed(), pure pipes or derived streams instead. - Follow the project's
ChangeDetectionStrategy(OnPushwhere used); never paper over stale views with arbitraryChangeDetectorRef.detectChanges()without finding why the input reference, signal orasyncpipe did not notify Angular.
2. Dependency injection and provider scopes
- Follow the project's DI style (
inject()function vs constructor injection) consistently. - Choose the narrowest appropriate provider scope and understand instance lifetime:
providedIn: 'root': app-wide singletons (auth, API clients, global caches) that live for the application's lifetime; ensure they do not retain stale feature state across route or user changes.- Route
providers: [...]: feature-scoped services shared across a route subtree and destroyed when leaving the route. - Component
providers: [...]/viewProviders: [...]: per-component instance state (complex form coordinators, local facade services) destroyed with the component (ngOnDestroy/DestroyRef).
- Never accidentally provide a stateful singleton service in both
rootand a component'sprovidersarray unless a separate per-component instance is deliberate. - Use
InjectionToken<T>for configuration objects, environment values and abstract contracts.
3. Lifecycle and resource cleanup
- Register cleanup for timers, manual subscriptions, DOM listeners and third-party instances using
DestroyRef.onDestroy(...),takeUntilDestroyed(), orngOnDestroy().
Before you finish
- Components have a single clear responsibility and typed inputs/outputs.
- No side effects or expensive calculations inside template expressions or getters.
- Every service is provided at the intended scope (
root, route, or component) without accidental duplicate instances. - Component and service resources clean up on destroy.
Csomagban lévő fájlok 2
LICENSE.txtSKILL.md
