我试图使用ngInfinitescroll加载数据,但得到的错误不明白为什么会出现,尽管声明了所有所需的依赖项。我的工作,http://jsfiddle.net/ey0c2n1t/
<div class="clusterize">
<table infinite-scroll="loadMore()" infinite-scroll-distance="1">
<thead>
<tr>
<th>Headers</th>
</tr>
</thead>
</table>
<div>
<table>
<tbody>
<tr ng-repeat="value in dataFilter = (data | limitTo:numberToDisplay)">
<td>{{value.id}}</td>
</tr>
</tbody>
</table>
</div>JS
var App = angular.module('App', ['infinite-scroll']);
App.directive('whoiam', function($http) {
return {
restrict: 'EA',
templateUrl: 'whoiam.html',
controller: ctrlr
}
function ctrlr($scope) {
$scope.data = [];
$scope.numberToDisplay = 100;
$http.get('https://jsonplaceholder.typicode.com/comments').success(function(data) {
$scope.data = data;
});
loadMore = function() {
alert("test");
if (this.numberToDisplay + 5 < $scope.data.length) {
this.numberToDisplay += 5;
} else {
this.numberToDisplay = $scope.data.length;
}
}
}
});发布于 2019-02-25 10:58:32
在项目中引用的AngularJS版本(v1.0.3)与要引用的ngInfiniteScroll版本(v1.3.0)不兼容。
此错误告诉您,infiniteScrollDirective正在尝试注入$interval服务,但是无法找到该服务的提供程序。
这是因为$interval服务在AngularJS 1.0.3中不可用。
将示例中的AngularJS版本更新为最新版本(v1.4.8)解决了错误。
注意,bower.json项目的ngInfiniteScroll文件依赖于AngularJS版本>= 1.2x。
"dependencies": {
"angular": ">=1.2.0"
}https://stackoverflow.com/questions/54862440
复制相似问题