Angular - Lifecycle Hooks
Given the following Angular component code, what will be logged to the console when the component is initialized?
import { Component, AfterContentInit, ContentChild, ElementRef } from '@angular/core';
@Component({
selector: 'child-comp',
template: ` `
})
export class ChildComp implements AfterContentInit {
@ContentChild('projected') projectedContent!: ElementRef;
ngAfterContentInit() {
console.log(this.projectedContent.nativeElement.textContent.trim());
}
}
// Usage in parent template:
// Hello World
