user1532669 user1532669 - 5 months ago 20
AngularJS Question

Error $window.height is not a function - ngInfiniteScroll with angularjs

I'm trying to load data dynamically with ngInfiniteScroll and I'm having a problem where I'm getting

$window.height is not a function.


Here's a fiddle, it's not quite working and I'm not sure why, the data doesn't display on the fiddle yet it does on my local machine.

I'm using ngInfiniteScroll and I'm getting this error:

TypeError: $window.height is not a function

windowBottom = $window.height() + $window.scrollTop();


Anyone have any idea why this error appears and how to sort it?

Thank you

Answer

Your fiddle doesn't work due to a module instantiation error. Regardless, $window is a reference to the global window object, and it is not a jqLite/jQuery object. You need to wrap it before trying to access jqLite/jQuery methods.

var windowEl = angular.element($window);
windowEl.height();
Comments