Javascript ng无限滚动禁用与$scope.disabled配对

Javascript ng无限滚动禁用与$scope.disabled配对,javascript,angularjs,angularjs-directive,angularjs-scope,nginfinitescroll,Javascript,Angularjs,Angularjs Directive,Angularjs Scope,Nginfinitescroll,我无法将ng无限滚动设置为禁用。问题是它不起作用,当用户到达页面底部时,滚动没有被阻止,我可以滚动更多并发生多个调用,而不是只有一个调用(因为滚动应该被禁用)。 似乎我对$scope.infinite\u有问题 <script> var myApp = angular.module('MyApp', ['infinite-scroll']); myApp.controller('DemoController', function($scope,

我无法将ng无限滚动设置为禁用。问题是它不起作用,当用户到达页面底部时,滚动没有被阻止,我可以滚动更多并发生多个调用,而不是只有一个调用(因为滚动应该被禁用)。 似乎我对$scope.infinite\u有问题

<script>

        var myApp = angular.module('MyApp', ['infinite-scroll']);

        myApp.controller('DemoController',  function($scope, $http) {
            $scope.data_search = [];
            $scope.data_items = [];
            var json_url = some_url_example;
            $scope.infinite_disabled = false;
            var fun = 0;

            $scope.loadMore = function() {

                if ($scope.infinite_disabled) return;
                fun++;
                console.log("call " + fun + " " + $scope.infinite_disabled);
                $scope.infinite_disabled = true;
                console.log("call " + fun + " " + $scope.infinite_disabled);

                if (condition) {

                    $http.get(json_url)
                    .then(function(response) {

                        $scope.data_search.push(response.data);
                        var new_items = response.data.Items;

                        for(var i=0; i<new_items.length; i++) {
                            $scope.data_items.push(new_items[i]);
                        }

                        json_url = some_example_url;
                    });
                }
                $scope.infinite_disabled = false;
                console.log("call " + fun + " " + $scope.infinite_disabled);
            }
        });

    </script>

<div ng-controller='DemoController'>
        <div infinite-scroll='loadMore()' infinite-scroll-distance='1' infinite-scroll-disabled='infinite_disabled'>
            <ul>
                <li ng-repeat='item in data_items'>{{item}}</li>
            </ul>
        </div>
    </div>
当我到达页面底部时,滚动未被阻止,滚动次数越多,呼叫次数越多

nginfinite_demo.html:29 call 2 false
nginfinite_demo.html:31 call 2 true
nginfinite_demo.html:49 call 2 false
nginfinite_demo.html:29 call 3 false
nginfinite_demo.html:31 call 3 true
nginfinite_demo.html:49 call 3 false
nginfinite_demo.html:29 call 4 false
nginfinite_demo.html:31 call 4 true
nginfinite_demo.html:49 call 4 false
nginfinite_demo.html:29 call 2 false
nginfinite_demo.html:31 call 2 true
nginfinite_demo.html:49 call 2 false
nginfinite_demo.html:29 call 3 false
nginfinite_demo.html:31 call 3 true
nginfinite_demo.html:49 call 3 false
nginfinite_demo.html:29 call 4 false
nginfinite_demo.html:31 call 4 true
nginfinite_demo.html:49 call 4 false