我是angularjs的新手。问题是我从第一个函数发送一些文本到数据库
$scope.fn_PostStatus = function () {
var param = {
statusText: $scope.TxtStatus,
};
var Post = MediaService.Status(param);
Post.then(function (msg) {
$scope.UserData = msg.data.RMessage
if (msg.data.RCode == 1) {
window.location.href = '/Media/NewsFeed/';
}
else {
if (msg.data.RCode == 2) {
swal("Something went wrong please come back later.", msg.data.RMessage, "error")
}
}
}, function (msg) {
});
}
我还想将二进制大对象(Blob)发送到第一个函数指向的相同URL 这是第二个功能
$scope.uploadme;
$scope.uploadImage = function () {
var fd = new FormData();
var imgBlob = dataURItoBlob($scope.uploadme);
fd.append('file', imgBlob);
$http.post(
ServiceURL + "StatusPost",
fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
}
)
.success(function (response) {
console.log('success', response);
})
.error(function (response) {
console.log('error', response);
});
}
是否可以将两个函数合并为一个函数并只生成一个http post请求?