File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -23,26 +23,26 @@ angular.module('myApplication', ['angular-whenScrolled']);
23
23
24
24
``` js
25
25
angular .controller (" demo" , function ($scope , $http ) {
26
- $scope .users = [];
27
- $scope .cantUsers = 0 ;
26
+ $scope .items = [];
27
+ $scope .totalItems = 0 ;
28
28
$scope .startList = 0 ;
29
29
$scope .stopLoadingData = false ;
30
30
31
31
$scope .more = function () {
32
32
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 );
40
40
$scope .startList += 10 ;
41
41
});
42
42
};
43
43
$scope .loading = false ;
44
44
};
45
- $scope .more ();
45
+ $scope .more ();// twice execute-> controller:load and scroll:load
46
46
});
47
47
```
48
48
* html:
You can’t perform that action at this time.
0 commit comments