如何在 angular 资源保存方法中发送带有 id 的“表单数据”?

How to send the `form data` with id's in angular resource save method?

我需要使用 angular 保存方法 ('post') 保存数据。我怎样才能发送必要的 idform data?

目前我收到“无效的 HTTP 状态代码 405”错误。

这是我的 controller.js:

$scope.uploadFile = function ( newFile, id ) {
    var data = new FormData();

    server.uploadXML.save({
    //passing id's
        packageId: $scope.packageId, 
        contractorId : $scope.contractorId,
        contractId : id

    }, { save: {
        //passing data..is it correct?
        data: newFile[0]
    }}); 
}

这是我的 server.js:

(function () {
    "use strict";
    angular
    .module("tcpApp")
    .factory("server", ['$resource', function ($resource) {

        var base = 'http://azvsptcsdev02:678/_vti_bin/CPMD.WEBSERVICE/ProjectInfoService.svc/';

        return {
            uploadXML   : $resource( base + 'UploadContract/:packageId/:contractorId/:contractId')
        }
    }]);
})();

您需要指定请求的类型.. GET/POST/PUT 等等

405表示方法不被允许,要么请求类型错误,要么端点未定义。

希望对您有所帮助。