1

Angular 2 scroll event getting height is null.

[sample]: https://plnkr.co/edit/RZSQkd0nqolYv3NBvArG?p=preview
Tameshwar
  • 789
  • 1
  • 10
  • 17

1 Answers1

1

Plunker example

Seems what you want is

  onScroll(){
    console.log('clientHeight: ' + this._el.clientHeight);
    console.log('offsetHeight: ' + this._el.offsetHeight);
  }

See also Get div height with plain JavaScript

getAttribute() reads attributes. Attributes are visible in the DOM. clientHeight is a property.

See also Properties and Attributes in HTML

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • And how to implement, basic of infinite scroll. [https://plnkr.co/edit/RZSQkd0nqolYv3NBvArG?p=preview] – Tameshwar Apr 14 '16 at 10:43
  • I haven't done an infinite scroll implementation myself yet. If you have more concrete questions I might be able to help but this is too broad. No idea where to start. – Günter Zöchbauer Apr 14 '16 at 10:45
  • I just started learning angular 2. it will be helpful for beginners. i have query. i want to create a directive like scroller, that will bound to my component, my component has service logic to update the data which has scroller. but my scroller has only event of scrolling up and scrolling down, how do i bind component method to scroller directive scroll event. – Tameshwar Apr 14 '16 at 10:53
  • Sorry, I think that's too broad for StackOverflow. Acually I don't even know what a scroller should do exactly. You might have a look at https://github.com/angular/material2 or https://github.com/justindujardin/ng2-material if they contain something like that. – Günter Zöchbauer Apr 14 '16 at 10:57