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

I am trying to inject a service in Angular js, but it gives following error. Service name is $upload. Code in my script located in the head of the page - `angular.module('myApp', ['angularFileUpload']);

Code in my controller $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(...) } };

Error displayed is : Error: [$injector:unpr] http://errors.angularjs.org/1.2.9/$injector/unpr?p0=%24uploadProvider%20%3C-%20%24upload

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

上一篇: 错误:错误:未知未知提供者

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