2017-12-18 93 views
-4

我想用角和PHP上傳圖像文件,但我在app.service越來越問題角js文件上傳 - 未捕獲的SyntaxError:意外的標記

錯誤行:app.service(「文件上傳」,[」 $ https:」開頭,函數($ HTTPS :) {

代碼

 app.service('fileUpload', ['$https:', function ($https:) { 
     this.uploadFileToUrl = function(file, uploadUrl){ 
      var fd = new FormData(); 
      fd.append('file', file); 

      $https:.post(uploadUrl, fd, { 
       transformRequest: angular.identity, 
       headers: {'Content-Type': undefined} 
      }) 

      .success(function(){ 
      }) 

      .error(function(){ 
      }); 
     } 
    }]); 

錯誤

question.js:20 Uncaught SyntaxError: Unexpected token : 
jquery.min.js:2 Uncaught Error: [$injector:modulerr] 
http://errors.angularjs.org/1.6.4/$injector/modulerr?..... 
at angular.js:38 
at angular.js:4920 
at q (angular.js:403) 
at g (angular.js:4880) 
at eb (angular.js:4802) 
at c (angular.js:1914) 
at Sc (angular.js:1935) 
at ue (angular.js:1820) 
at HTMLDocument.<anonymous> (angular.js:33367) 
at j (jquery.min.js:2) 

回答

1

變化$https:$http

app.service('fileUpload', ['$http', function ($http) { 
相關問題