Scroll to element on click in Angular 4

后端 未结 12 1043
逝去的感伤
逝去的感伤 2020-11-29 18:57

I want to be able to scroll to a target when a button is pressed. I was thinking something like this.

12条回答
  •  孤街浪徒
    2020-11-29 19:33

    You can achieve that by using the reference to an angular DOM element as follows:

    Here is the example in stackblitz

    the component template:

    Other content
    Some text to scroll

提交回复
热议问题