๐ค
Angular
Avoid common Angular mistakes โ subscription leaks, change detection, dependency injection, and module organization.
ๅฎๅ
จ้่ฟ
ๆ่ฝ่ฏดๆ
name: Angular slug: angular version: 1.0.1 description: Build reliable Angular apps avoiding RxJS leaks, change detection traps, and DI pitfalls.
When to Use
User needs Angular expertise โ component architecture, RxJS patterns, change detection, dependency injection, routing, and forms.
Quick Reference
| Topic | File |
|---|---|
| Components & change detection | components.md |
| RxJS & subscriptions | rxjs.md |
| Forms & validation | forms.md |
| Dependency injection | di.md |
| Routing & guards | routing.md |
| HTTP & interceptors | http.md |
Common Mistakes
OnPushwith mutated objects won't trigger change detection โ always create new reference:{...obj}or[...arr]@ViewChildis undefined in constructor/ngOnInitโ access inngAfterViewInitor later*ngForwithouttrackByre-renders entire list on any change โ addtrackByreturning stable ID- Manual
subscribe()without unsubscribe leaks memory โ useasyncpipe,takeUntilDestroyed(), or unsubscribe inngOnDestroy HttpClientreturns cold Observable โ eachsubscribe()fires new HTTP requestsetTimeout/setIntervaloutside NgZone โ change detection won't run, useNgZone.run()or signals- Circular DI dependency crashes app โ use
forwardRef()or restructure services ElementRef.nativeElementdirect DOM access breaks SSR โ useRenderer2or@defer- Route params via
snapshotmiss navigation changes โ useparamMapObservable for same-component navigation setValue()on FormGroup requires ALL fields โ usepatchValue()for partial updates
ๅฆไฝไฝฟ็จใAngularใ๏ผ
- ๆๅผๅฐ้พ่พAI๏ผWeb ๆ iOS App๏ผ
- ็นๅปไธๆนใ็ซๅณไฝฟ็จใๆ้ฎ๏ผๆๅจๅฏน่ฏๆกไธญ่พๅ ฅไปปๅกๆ่ฟฐ
- ๅฐ้พ่พAI ไผ่ชๅจๅน้ ๅนถ่ฐ็จใAngularใๆ่ฝๅฎๆไปปๅก
- ็ปๆๅณๆถๅ็ฐ๏ผๆฏๆ็ปง็ปญๅฏน่ฏไผๅ