Skip to content

Commit ea43a62

Browse files
committed
Update README.md
1 parent 7acad6a commit ea43a62

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@ angular.module('myApplication', ['angular-whenScrolled']);
2323

2424
```js
2525
angular.controller("demo", function ($scope, $http) {
26-
$scope.users = [];
27-
$scope.cantUsers=0;
26+
$scope.items = [];
27+
$scope.totalItems=0;
2828
$scope.startList = 0;
2929
$scope.stopLoadingData = false;
3030

3131
$scope.more = function () {
3232
if (!$scope.stopLoadingData) {
33-
$http.post("/app/users", {"startList": $scope.startList}).success(function (data) {
34-
$scope.cantUsers=data.cantTotalUsers;
35-
$scope.loading = true;
36-
$scope.stopLoadingData = !(data.users.length > 0);
37-
angular.forEach(data.users,function (key) {
38-
$scope.users.push(key);
39-
});
33+
$scope.loading = true;
34+
$http.post("/app/items", {"startList": $scope.startList}).success(function (data) {
35+
$scope.totalItems=data.totalItems;
36+
angular.forEach(data.items,function (key) {
37+
$scope.items.push(key);
38+
});
39+
$scope.stopLoadingData = ($scope.items.length === $scope.totalItems);
4040
$scope.startList += 10;
4141
});
4242
};
4343
$scope.loading = false;
4444
};
45-
$scope.more();
45+
$scope.more();//twice execute-> controller:load and scroll:load
4646
});
4747
```
4848
* html:

0 commit comments

Comments
 (0)