Angular Pass请求正文到一个宁静的接口

时间:2015-08-30 20:45:33

标签: angularjs rest

我的restful控制器从角度POST接收一个空的Request Body,我不知道为什么。

这是我的控制器的代码:

adminController.controller('ModalCtrl', ['$scope', '$modal', '$log', 'Profile', 'AvailableProfiles',
        function ($scope, $modal, $log, Profile, AvailableProfiles) {
    $scope.open = function (uuid, profile) {
        var modalInstance = $modal.open({
            animation: true,
            templateUrl: 'myModalContent.html',
            controller: 'ModalInstanceCtrl',
            resolve: {
                profile: function () {
                    return profile;
                },
                AvailableProfiles: function () {
                    return AvailableProfiles;
                }
            }
        });
        modalInstance.result.then(function () {
            Profile.save({uuid: uuid}, {profile: profile});
        }, function () {});
    };
}]); 

这是我服务的代码:

adminService.factory('Profile', ['$resource',
    function($resource, uuid, profile) {
        return $resource(baseUrl + 'candidate/:uuid/profile', {profile}, {
            save: {method: 'POST', params: {uuid: uuid}},
        });
    }
]);

有关为什么此个人资料对象未被传递到帖子中的任何想法?

1 个答案:

答案 0 :(得分:0)

在个人资料对象上调用保存。

modalInstance.result.then(function () {
    profile.$save({uuid: uuid});
}, function () {});