Javascript 当滚动位置到达底部时,如何推动阵列中的项目?

Javascript 当滚动位置到达底部时,如何推动阵列中的项目?,javascript,angular,Javascript,Angular,您能告诉我当滚动位置到达底部时,如何在阵列中推动项目吗?我在添加滚动事件的地方生成一个指令。当用户滚动到底部时,我想在数组中添加新项目 这是我的密码: 我从以下链接获取帮助: 我们是否可以在角度之外运行滚动代码,当到达底部并在数组中添加项目时,告诉角度 我想您可以检查目标的scrollTop值是否等于目标的scrollHeight-offsetHeight值 scroll = (e): void => { //e.target.scrollTop = current scr

您能告诉我当滚动位置到达底部时,如何在阵列中推动项目吗?我在添加滚动事件的地方生成一个
指令
。当用户滚动到
底部时,我想在数组中添加新项目

这是我的密码:

我从以下链接获取帮助:

我们是否可以在
角度
之外运行
滚动
代码,当到达底部并在数组中添加项目时,告诉
角度

我想您可以检查目标的
scrollTop
值是否等于目标的
scrollHeight-offsetHeight

  scroll = (e): void => {
    //e.target.scrollTop = current scroll position
    //e.target.scrollHeight - e.target.offsetHeight = to calculate the bottom. equivalent to scrollTopMax in FF
    if (e.target.scrollTop == e.target.scrollHeight - e.target.offsetHeight) {
      console.log('You reached the bottom!');
      //Push item into array
    }
  };

要将项目推入数组,请查看array.push方法的属性

,您应该改用HostListener,我不确定您是否询问如何将项目推入数组,或者是否已触底。
  scroll = (e): void => {
    //e.target.scrollTop = current scroll position
    //e.target.scrollHeight - e.target.offsetHeight = to calculate the bottom. equivalent to scrollTopMax in FF
    if (e.target.scrollTop == e.target.scrollHeight - e.target.offsetHeight) {
      console.log('You reached the bottom!');
      //Push item into array
    }
  };