0
컨트롤러 외부의 텍스트 영역에 값을 전달하거나 설정할 수 없습니다. 엑셀을 업로드하고 업로드 상태와 관련하여 일부 데이터를 텍스트 영역으로 설정하려고합니다.각도 서비스 범위 및 설정 값
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);
};
}]);
, 당신은 그 때는 대신 일단 .success과에는 .error 콜백의 사용해야합니다
및 컨트롤러처럼해야한다. 내가 옳다면 지금은 더 이상 사용하지 않을 것입니다. 자세한 내용은 '$ http'API를 읽으십시오. –