I
I
Ivan Stroykin2017-07-19 13:10:13
Angular
Ivan Stroykin, 2017-07-19 13:10:13

How to automatically scroll to a table?

Good day,
I came across the fact that on laptops, or small screens, some forms take up a lot of space, and when you request information, a data table appears somewhere below. I decided to make the page scroll to it when the table appears. But here's something that doesn't work. Prepared a place Plunker
Tried through but get undefined this.el.nativeElement.scrollTop = 0;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Zuev, 2017-07-19
@StivinKing

There are many options, for example, one of the options .
We define the template reference variable . We monitor the appearance of the table on the page and scroll to it if it appears.

@ViewChild('table') 
set tableEl(el: ElementRefl) {
  if(el) {
    el.nativeElement.scrollIntoView();
  }
}

Live example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question