Scroll to element on click in Angular 4

后端 未结 12 1031
逝去的感伤
逝去的感伤 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:35

    I need to do this trick, maybe because I use a custom HTML element. If I do not do this, target in onItemAmounterClick won't have the scrollIntoView method

    .html

    .ts

    onItemAmounterClick(target){
      target.__ngContext__[0].scrollIntoView({behavior: 'smooth'});
    }
    

提交回复
热议问题