Angular - 添加无限滚动模块后未知提供者
Angular - Unknown Provider after adding infinite scroll module
我正在尝试使用 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控制器的代码
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);
};
}]);
app.controller('MyCtrl', ['$scope', 'Upload', '$timeout','$http', function ($scope, Upload, $timeout, $http) {
在上面的语句中,你正在插入
Upload
作为 angular 中的一项服务。提供商/服务似乎缺失。
我正在尝试使用 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控制器的代码
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);
};
}]);
app.controller('MyCtrl', ['$scope', 'Upload', '$timeout','$http', function ($scope, Upload, $timeout, $http) {
在上面的语句中,你正在插入
Upload
作为 angular 中的一项服务。提供商/服务似乎缺失。