AngularJS ui-scroll not working (Cannot set property 'overflowY' of undefined)

869 Views Asked by At

New to AngularJS. Following ui-scroll is not working. Appreciate any help.

https://plnkr.co/edit/PVCWRf1DaVtt4j7z15wx?p=preview

Trying implement simple ui-scroll without any jquery libraries. Below is sample code making it to work so that i can expand it to be implemented in app.

html

<!DOCTYPE html>
<html>
  <head>
    <title>Hospital</title>
  </head>
  <body>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.js"></script>
    <script src="scroll.js"></script>
    <script src="ui-scroll.js"></script>
    <link rel="stylesheet" type="text/css" href="scroll.css">

    <div ng-app="scrollerTestApp" ng-controller="ScrollerController">
      <div  ui-scroll="movie in movieDataSource">
        <h2>{{ movie.description }}</h2>
      </div>
    </div>
  </body>
</html>

scroll.js

var appModule = angular.module('scrollerTestApp', ['ui.scroll'])
  .controller('ScrollerController', ['$scope', function($scope) {

    $scope.movieDataSource = {
      get: function(index, count, callback) {
        var i, items = [],
          item;

        var min = 1;
        var max = 100;

        for (i = index; i < index + count; i++) {
          if (i < min || i > max) {
            continue;
          }
          item = {
            description: "Item : " + i,
            imageURL: "http://placehold.it/96x96&text=" + i
          };
          items.push(item);
        }
        callback(items);
      }
    }
  }]);
2

There are 2 best solutions below

0
On

Since angular-ui-scroll v1.6.0 the ui.scroll.jqlite module was deprecated. All necessary instructions had been incapsulated into ui.scroll module. So, the best solution would be to upgrade the angular-ui-scroll dependency.


If you are using angular-ui-scroll before v1.6.0, you should add ui.scroll.jqlite module to the App explicitly:

angular.module('scrollerTestApp', ['ui.scroll.jqlite', 'ui.scroll'])

Also, it means that ui-scroll-jqlite[.min].js should be added to your scripts/build before ui-scroll[.min].js.

0
On

The problem you have is you're lack of ui-scroll-jqlite.

According to the documentation:

File dist/ui-scroll-jqlite.js houses implementations of the above methods and also has to be loaded in your page. Please note that the methods are implemented in a separate module 'ui.scroll.jqlite' and this name should also be included in the dependency list of the main module.

that said, I let your plnkr edited.

Hope it helps ;).