Angular - Lifecycle HooksWhich of the following is the correct way to implement the ngOnDestroy lifecycle hook in an Angular component?Adestroy() { console.log('Destroyed'); }BonDestroy() { console.log('Destroyed'); }CngOnDestroy() { console.log('Destroyed'); }DngDestroy() { console.log('Destroyed'); }Check Answer
Step-by-Step SolutionSolution:Step 1: Recall correct lifecycle hook method nameThe Angular lifecycle hook for destruction is named exactly ngOnDestroy.Step 2: Verify method signatureMethod must be named ngOnDestroy with parentheses and body; ngOnDestroy() { console.log('Destroyed'); } matches this exactly.Final Answer:ngOnDestroy() { console.log('Destroyed'); } -> Option CQuick Check:Correct ngOnDestroy syntax = ngOnDestroy() { console.log('Destroyed'); } [OK]Quick Trick: Use exact hook names like ngOnDestroy() [OK]Common Mistakes:Misspelling lifecycle hook namesOmitting parentheses in method declaration
Master "Lifecycle Hooks" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Angular Fundamentals - How Angular differs from React and Vue - Quiz 13medium Angular Fundamentals - What is Angular - Quiz 12easy Angular Fundamentals - Why Angular for enterprise applications - Quiz 5medium Angular Modules - Module lazy loading preview - Quiz 8hard Component Interaction - ng-content for slot-based composition - Quiz 4medium Components - Why components are the building blocks - Quiz 2easy Directives - *ngFor for list rendering - Quiz 11easy Lifecycle Hooks - ngOnDestroy for cleanup - Quiz 13medium Pipes - Creating custom pipes - Quiz 7medium TypeScript in Angular - Generics in Angular services - Quiz 12easy