2
이 문제는 며칠 동안 지속되었습니다.
나는 angular file upload을 사용하여 이미지를 업로드합니다. 이미지를 서버에 업로드 할 수 있으며 서버로부터 응답 이미지 URL을받을 수 있습니다.함수에서 각도 컨트롤러 범위로 데이터를 전달하는 방법
하지만 내 컨트롤러의 $scope
에 응답 이미지 URL을 가져올 수 없으므로 외부 컨트롤러에 대한 URL을 보존 할 수 없습니다.
다음 내용은 제 코드의 일부입니다. 사전에
.controller('AppController', ['$scope', 'FileUploader', function ($scope, FileUploader) {
$scope.uploader = new FileUploader({
url: 'http://www.example.com/upload',
});
$scope.imgurl = {}; // I want to put the response url here.
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
$scope.uploader.onCompleteItem = function (fileItem, response, status, headers) {
console.info('onCompleteItem', fileItem, response, status, headers);
console.info(response.name); // here I can get the response url
};
}]);
감사합니다.