3

AngularJS 的新手。跟随 ui-scroll 不起作用。感谢任何帮助。

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

尝试在没有任何 jquery 库的情况下实现简单的 ui-scroll。下面是使其工作的示例代码,以便我可以扩展它以在应用程序中实现。

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>

滚动.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);
      }
    }
  }]);
4

2 回答 2

0

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.

于 2017-12-11T21:21:56.657 回答
0

你的问题是你缺乏ui-scroll-jqlite.

根据文档:

文件 dist/ui-scroll-jqlite.js 包含上述方法的实现,也必须加载到您的页面中。请注意,这些方法在单独的模块“ui.scroll.jqlite”中实现,并且该名称也应包含在主模块的依赖项列表中。

也就是说,我让您的plnkr 进行了编辑。

希望能帮助到你 ;)。

于 2016-11-16T22:52:07.687 回答