I have an element that that is conditionally inserted with an *ngIf condition. When it is inserted I want to scroll it into view. The following technique works but it seems clumsy and I would like to improve it.
<app-text-create id="textcreate" *ngIf="modeNewEntry"
(load)="document.getElementById('textcreate').scrollIntoView()"
></app-text-create>
When the component state property modeNewEntry goes true the text entry box gets inserted on the bottom of the page. Without the scrollIntoView() call it is generally not visible.
Is there a better way to get access to the HTMLElement than the document.getElementById(..) expression?
PS. The IDE I am using, WebStorm, thinks the document reference as undefined even though this does works. Is that a bug or is there a reason for that?