In my html i have async pipe and ElementReference. In ts iam setting data comes with async pipe to nativeElement.innerHTML but iam getting this on console.
Cannot read properties of undefined (reading 'nativeElement')
Html
<div *ngIf="(article$ | async) as article">
<div #articleBody>
</div>
</div>
Ts
@ViewChild("articleBody") articleBody: ElementRef;
ngAfterViewInit() {
this.article$ = this.articleService.article$.pipe(
tap(x => {
this.articleBody.nativeElement.innerHTML = x.body
})
)
}
How can i solve this ?