Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 角函数无法识别_Angularjs_Onscroll - Fatal编程技术网

Angularjs 角函数无法识别

Angularjs 角函数无法识别,angularjs,onscroll,Angularjs,Onscroll,每次用户接近底部时,我需要加载20个表项,其中包含600个表项。我以这种方式使用onscroll,但它无法识别角度函数,在本例中为loadMore(): {{$index+1}} {{x.city} var-app=angular.module('myApp',[]); app.controller('customersCtrl',函数($scope,$http){ $scope.limit=20; $http.get('city.json')。然后(函数(响应){ $scope.city=r

每次用户接近底部时,我需要加载20个表项,其中包含600个表项。我以这种方式使用onscroll,但它无法识别角度函数,在本例中为loadMore():


{{$index+1}}
{{x.city}
var-app=angular.module('myApp',[]);
app.controller('customersCtrl',函数($scope,$http){
$scope.limit=20;
$http.get('city.json')。然后(函数(响应){
$scope.city=response.data;
});
$scope.loadMore=function(){
$scope.limit=$scope.limit+20;
}
});
所以,我得到了这个错误:


ReferenceError:loadMore未定义

onscroll正在搜索JavaScript函数,不在角度范围内。。您需要在该元素上的register scroll事件中写入一个指令,并将回调传递给指令,如
my scroll=“loadMore()”
您应该使用一个指令,如ng infinite scroll
<body>

<div ng-app="myApp" ng-controller="customersCtrl"> 
<div id="tabla" onscroll="loadMore()">
<table>

  <tr ng-repeat="x in city | limitTo: limit:begin">
    <td> {{ $index +1 }} </td>
    <td> {{ x.city }} </td>
  </tr>
</table>
</div>
</div>

<script>
var app = angular.module('myApp', []);
    app.controller('customersCtrl', function($scope, $http) {
        $scope.limit = 20;
        $http.get('city.json').then(function (response) {
         $scope.city = response.data; 
});

$scope.loadMore= function(){

         $scope.limit = $scope.limit+20;
}
});
</script>

</body>
</html>