How can I pass this
to a function assigned to my window.onscroll
event?
I am trying to trigger myFunction()
when a certain condition is met. I need to check this condition onscroll
init() {
window.onscroll = function() {
if(this.currentItemCount() > this.totalElements){
this.totalElements = this.currentItemCount();
this.myFunction();
}
};
}
However I get an error that this.currentItemCount()
is not a function. I know that I need to pass this
to window.onscroll
but I cannot figure out the correct syntax.