我正在尝试使用Angular的无限滚动模块,并且不知道为什么会出现此错误。
以下是我从chrome控制台复制的错误。
Error: [$injector:unpr] Unknown provider: UploadProvider <- Upload <- MyCtrl
http://errors.angularjs.org/1.4.4/$injector/unpr?p0=UploadProvider%20%3C-%20Upload%20%3C-%20MyCtrl
at angular.js:68
at angular.js:4284
at Object.getService [as get] (angular.js:4432)
at angular.js:4289
at getService (angular.js:4432)
at Object.invoke (angular.js:4464)
at extend.instance (angular.js:9093)
at nodeLinkFn (angular.js:8205)
at compositeLinkFn (angular.js:7637)
at publicLinkFn (angular.js:7512)
以下是index.html的代码
<body ng-app="fileUpload" ng-controller="MyCtrl">
<div>
<div infinite-scroll='loadMore()' infinite-scroll-distance="addmore(offer.time_posted)">
<div ng-repeat="offer in offerlist">{{offer.imageurl}} {{offer.time_posted}} {{offer.category}} {{offer.offercode}}</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script>
<script src="controller13.js"></script>
<script src="ng-infinite-scroll.js"></script>
<script src="ng-infinite-scroll.min.js"></script>
</body>
以下是Angular Controller的代码
var app = angular.module('fileUpload', ['infinite-scroll']);
var imageurl;
var f;
app.controller('MyCtrl', ['$scope', 'Upload', '$timeout','$http', function ($scope, Upload, $timeout, $http) {
var testttt = '1279';
var id = '123';
var refresh = function() {
$http.get('/fetchtweet', testttt).success(function(response) {
console.log("I got the data I requested");
$scope.offerlist = response;
$scope.offer = "";
});
};
refresh();
$scope.addmore = function(time_posted)
{
console.log(time_posted);
};
}]);
答案 0 :(得分:0)
app.controller('MyCtrl', ['$scope', 'Upload', '$timeout','$http', function ($scope, Upload, $timeout, $http) {
在上面的陈述中,您正在插入
Upload
作为角度服务。似乎缺少提供者/服务。