๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ
ๅฐ้พ™่™พๅฐ้พ™่™พAI
๐Ÿค–

Angular

Avoid common Angular mistakes โ€” subscription leaks, change detection, dependency injection, and module organization.

ไธ‹่ฝฝ2.0k
ๆ˜Ÿๆ ‡3
็‰ˆๆœฌ1.0.1
่‡ชๅŠจๅŒ–่„šๆœฌ
ๅฎ‰ๅ…จ้€š่ฟ‡

ๆŠ€่ƒฝ่ฏดๆ˜Ž


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

TopicFile
Components & change detectioncomponents.md
RxJS & subscriptionsrxjs.md
Forms & validationforms.md
Dependency injectiondi.md
Routing & guardsrouting.md
HTTP & interceptorshttp.md

Common Mistakes

  • OnPush with mutated objects won't trigger change detection โ€” always create new reference: {...obj} or [...arr]
  • @ViewChild is undefined in constructor/ngOnInit โ€” access in ngAfterViewInit or later
  • *ngFor without trackBy re-renders entire list on any change โ€” add trackBy returning stable ID
  • Manual subscribe() without unsubscribe leaks memory โ€” use async pipe, takeUntilDestroyed(), or unsubscribe in ngOnDestroy
  • HttpClient returns cold Observable โ€” each subscribe() fires new HTTP request
  • setTimeout/setInterval outside NgZone โ€” change detection won't run, use NgZone.run() or signals
  • Circular DI dependency crashes app โ€” use forwardRef() or restructure services
  • ElementRef.nativeElement direct DOM access breaks SSR โ€” use Renderer2 or @defer
  • Route params via snapshot miss navigation changes โ€” use paramMap Observable for same-component navigation
  • setValue() on FormGroup requires ALL fields โ€” use patchValue() for partial updates

ๅฆ‚ไฝ•ไฝฟ็”จใ€ŒAngularใ€๏ผŸ

  1. ๆ‰“ๅผ€ๅฐ้พ™่™พAI๏ผˆWeb ๆˆ– iOS App๏ผ‰
  2. ็‚นๅ‡ปไธŠๆ–นใ€Œ็ซ‹ๅณไฝฟ็”จใ€ๆŒ‰้’ฎ๏ผŒๆˆ–ๅœจๅฏน่ฏๆก†ไธญ่พ“ๅ…ฅไปปๅŠกๆ่ฟฐ
  3. ๅฐ้พ™่™พAI ไผš่‡ชๅŠจๅŒน้…ๅนถ่ฐƒ็”จใ€ŒAngularใ€ๆŠ€่ƒฝๅฎŒๆˆไปปๅŠก
  4. ็ป“ๆžœๅณๆ—ถๅ‘ˆ็Žฐ๏ผŒๆ”ฏๆŒ็ปง็ปญๅฏน่ฏไผ˜ๅŒ–

็›ธๅ…ณๆŠ€่ƒฝ