Angular 2/4 Will ElementRef break in Angular to generic?

I have a question:

Would use ElementRef.nativeElement

to read a property value (like 'scrollHeight') count as DOM interaction and therefore violate Angular Universal?

ElementRef seems to be the only way to read a property from an element: stack overflow

Example:

HTML:

<div #test1></div>

      

TS:

@ViewChild('test1') test1: ElementRef;

ngOnInit() {
  console.log(this.test1.nativeElement.scrollHeight);
}

      

+3


source to share





All Articles