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);
}
}
}]);