注入角度指令和服务。 [$ injector:unpr]错误

我正在尝试在Angular js中注入一个服务,但是它给出了以下错误。 服务名称是$ upload。 代码位于页面头部的脚本中 - `angular.module('myApp',['angularFileUpload']);

在我的控制器中的代码$scope.onFileSelect = function($files) { for (var i = 0; i < $files.length; i++) { var file = $files[i]; $scope.upload = $upload.upload({ url: 'server/upload/url', data: {myObj: $scope.myModelObj}, file: file, // or list of files: $files for html5 only }).progress(function(evt) { console.log('percent: ' + parseInt(100.0 * evt.loaded / evt.total)); }).success(function(data, status, headers, config) { console.log(data); }); //.error(...) } }; $scope.onFileSelect = function($files) { for (var i = 0; i < $files.length; i++) { var file = $files[i]; $scope.upload = $upload.upload({ url: 'server/upload/url', data: {myObj: $scope.myModelObj}, file: file, // or list of files: $files for html5 only }).progress(function(evt) { console.log('percent: ' + parseInt(100.0 * evt.loaded / evt.total)); }).success(function(data, status, headers, config) { console.log(data); }); //.error(...) } };

显示的错误是:错误:[$ injector:unpr] http://errors.angularjs.org/1.2.9/$injector/unpr?p0=%24uploadProvider%20%3C-%20%24upload

链接地址: http://www.djcxy.com/p/77659.html

上一篇: Inject angular directive and service. [$injector:unpr] error

下一篇: Post form data to rest resource in angularJS