0
コントローラ外のテキスト領域に値を渡したり設定することはできません。 私はExcelをアップロードしており、アップロード状況に関しては、一部のデータをテキスト領域に設定したいと考えています。 これは、これまでの私のコードです:サービスへの角度範囲と設定値
app.service('fileUpload', ['$http', function ($http) {
this.uploadFileToUrl = function(file, uploadUrl, commentArea){
var fd = new FormData();
fd.append('file', file);
$http.post(uploadUrl, fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
})
.success(function(){
/* commentArea.append('This is not working');
commentArea = 'This is not working';
$scope.outputImportObject = 'This is not working';
*/
alert('The file was succesfully uploaded!');
})
.error(function(){
alert('There was an error while inserting the file!');
});
}
}]);
app.controller('UploadCtrl', ['$scope', 'fileUpload', function($scope, fileUpload){
$scope.uploadFile = function(){
$scope.outputImportObject = 'This is working';
var file = $scope.myFile;
var commentArea = $scope.outputImportObject;
fileUpload.uploadFileToUrl(file, ws_url+'upload_excel.php',commentArea);
};
}]);
、あなたが.then代わり.successと.ERRORコールバックを使用する必要があります:
とあなたのコントローラは次のようにする必要があります。もし私が正しいのであれば、彼らは現在廃止されています。より多くのために角度の '$ http' APIを読んでください –