How Scroll to a div in ng-template?

642 views Asked by At

Im using ngb modal to for a pop up where the content is set inside a <ng-template>. On submit (on error) I need to automatically scroll down to the error section. I tried @viewchild on the <div #error> but since its part of the template the viewchild value is always undefined. What would be the best way to access a div inside a template or to scroll automatically on ngbmodal to ots scroll height ?

1

There are 1 answers

1
Aleksandrus On BEST ANSWER

You don't need to use Angular for that. You can accomplish that with pure Javascript.

You could use <my-element id="someid"></my-element>

And then, with pure javascript, document.getElementById("someid").scrollIntoView()