-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
59 lines (48 loc) · 1.48 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>UI.SCROLL</title>
</head>
<body ng-app="myModule">
<div ng-controller="initController as ctrl">
<div ui-scroll-viewport style="overflow-y:auto;display:block;height:150px;">
<div ui-scroll="element in ctrl.datasource" buffer-size="5" padding="1">
<p ng-bind="element._id"></p>
</div>
</div>
</div>
<script type="text/javascript" src="node_modules/angular/angular.min.js"></script>
<script type="text/javascript" src="node_modules/angular-ui-scroll/dist/ui-scroll.min.js"></script>
<script>
var myModule = angular.module('myModule', ['ui.scroll']);
myModule.controller('initController', ['initFactory', function (initFactory) {
var vm = this;
initFactory.getData();
vm.datasource = initFactory.scrollData();
}]);
myModule.factory('initFactory', ['$http', '$timeout', function ($http, $timeout) {
var elements = {};
function getData() {
return $http.get('data.json').then(function (response) {
elements = response.data.data;
return;
});
}
function scrollData() {
return {
get: function (index, count, success) {
$timeout(function () {
success(elements.slice(index, index + count));
}, 100);
}
};
}
return {
getData: getData,
scrollData: scrollData
};
}]);
</script>
</body>
</html>