How to read innerText from home component to Other components.

68 views
Skip to first unread message

Jey Sekar

unread,
Jul 23, 2020, 6:21:31 AM7/23/20
to Angular and AngularJS discussion
Hi,

I need to get 5 components innerText in app component .

I tried @viewchild but unable to achive. any clue?

export class AppComponent implements AfterViewInit {

@ViewChild("myDiv") divView: ElementRef;
@ViewChild("myDiv") linkone: LinkOneComponent;

ngAfterViewInit(){

console.log(this.divView);
this.divView.nativeElement.innerText = "Hello Angular 9!"; // I can get same Appcomponent innerText here
this.linkone.nativeElement.innerText // here am trying to read innerText from LinkOneComponent but nativeElement not available
}
Reply all
Reply to author
Forward
0 new messages