Angular Js文件上传 - 未捕获的SyntaxError:意外的令牌

问题描述 投票:-4回答:1

我想使用angular和php上传图像文件,但我在app.service遇到问题

错误行:app.service('fileUpload',['$ https:',function($ 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)
javascript angularjs
1个回答
1
投票

$https:改为$http

app.service('fileUpload', ['$http', function ($http) {
© www.soinside.com 2019 - 2024. All rights reserved.