
Angular Lifecycle
Covers the essential Angular lifecycle hooks you actually use day to day: ngOnInit for setup, ngOnDestroy for cleanup, ngOnChanges for input tracking, and AfterViewInit for DOM access. The examples are solid and show practical patterns like using Subject for cleanup subscriptions and checking SimpleChanges properly. It's current with Angular 21 and includes the OnPush change detection nuance, which matters when you're optimizing performance. The constructor versus ngOnInit guidance is helpful since that trips up newcomers constantly. If you're building Angular components beyond trivial ones, you'll hit these hooks, and having the patterns ready beats digging through docs every time.
- skills.sh installs
- 176
- GitHub stars
- 7
- last updated
- Aug 21, 2026
Install
$ npx -y skills add oguzhan18/angular-ecosystem-skills --skill angular-lifecycle --agent claude-codeInstalls into .claude/skills of the current project.
Files
Angular Lifecycle Hooks
Version: Angular 21 (2025) Tags: Lifecycle, Hooks, ngOnInit, ngOnChanges
References: Lifecycle Hooks • API
Best Practices
- Use OnInit for initialization
import { OnInit } from '@angular/core';
@Component({})
export class MyComponent implements OnInit {
ngOnInit() {
// Initialize data, call services
this.loadData();
}
}
- Use OnDestroy for cleanup
import { OnDestroy } from '@angular/core';
@Component({})
export class MyComponent implements OnDestroy {
private destroy$ = new Subject<void>();
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
}
- Use OnChanges for input changes
import { OnChanges, SimpleChanges } from '@angular/core';
@Component({})
export class MyComponent implements OnChanges {
@Input() data: any;
ngOnChanges(changes: SimpleChanges) {
if (changes['data']) {
console.log('Data changed:', this.data);
}
}
}
- Use AfterViewInit for DOM manipulation
import { AfterViewInit, ViewChild, ElementRef } from '@angular/core';
Sponsors
Details
- Repository
- github.com/oguzhan18/angular-ecosystem-skills
- Category
- Frontend Development
- First seen
- Jun 3, 2026
More from oguzhan18/angular-ecosystem-skills
All 45- Angular Di175
- Angular Viewchild174
- Angular Cypress172
- Angular Router172
- Angular Control Flow170
- Angular Zoneless170
- Nx170
- Angular Signals Http169
- Angular Ssr168
- Angular Injector165
- Angular Query160
- Shadcn Ng152
- Angular Tailwind245
- Angular Material233
- Rxjs214
- Angular Security211
- Angular Bootstrap205
- Angular Cdk201
- Angular Testing197
- Ngrx195
- Angular Animations194
- Angular I18n194
- Angular Services193
- Angular Performance192