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-code

Installs 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
1samhvw8 avatarfrontend-developmentsamhvw8/dotfilesMulti-framework frontend development. Frameworks: React 18+ (Suspense, hooks, TanStack), Vue 3 (Composition API, Pinia, Nuxt), Svelte 5 (Runes, SvelteKit), Angu174skills.sh installs
2srbhr avatartailwind-patternssrbhr/resume-matcherProduction-ready Tailwind CSS patterns for common website components: responsive layouts, cards, navigation, forms, buttons, and typography. Includes spacing sc170skills.sh installs
3pedronauck avatarui-ux-pro-maxpedronauck/skillsUI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 9 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind,168skills.sh installs
4modu-ai avatarmoai-domain-frontendmodu-ai/moai-adkFrontend development specialist covering React 19, Next.js 16, Vue 3.5, and modern UI/UX patterns with component architecture. Use when building web UIs, implem140skills.sh installs
5butterbase-ai avatardeploy-frontendbutterbase-ai/butterbase-skillsWalks you through the seven-step process to get a React, Next.js, or static site live on Butterbase, from setting environment variables...0skills.sh installs
6composiohq avatarsenior-frontendcomposiohq/awesome-claude-pluginsFrontend development skill for React, Next.js, TypeScript, and Tailwind CSS applications. Use when building React components, optimizing Next.js performance, an0skills.sh installs