Angular - Lifecycle Hooks
Consider this Angular component code snippet:
When used as
import { Component, AfterContentInit, ContentChild, ElementRef } from '@angular/core';
@Component({
selector: 'proj-comp',
template: ` `
})
export class ProjComp implements AfterContentInit {
@ContentChild('contentRef') content!: ElementRef;
ngAfterContentInit() {
console.log(this.content.nativeElement.textContent);
}
}When used as
<proj-comp><p>Test</p></proj-comp>, what error will occur and why?