【发布时间】:2016-12-21 11:08:36
【问题描述】:
在我的 Angular 应用程序中,我使用带有 JQuery 的 Dropzone 来上传文件。我成功地将文件上传到我的服务器并接收响应数据。现在我需要将该响应数据从 JQuery 传递到我的 AngularJS 控制器。
这是我的拖放区代码:
<script type="text/javascript">
Dropzone.autoDiscover = false;
$(document).ready(function() {
// Smart Wizard
$('#wizard').smartWizard({labelFinish:'Upload'});
$('#file-dropzone').dropzone({
url: "UploadData/",
maxFilesize: 1024000,
paramName: "uploadfile",
acceptedFiles: ".csv",
maxFiles: 1,
dictDefaultMessage: "Drop CSV file here",
maxThumbnailFilesize: 5,
dictMaxFilesExceeded: "You can only uplaod one file",
init: function() {
this.on("sending", function(file, xhr, formData){
$(".busy-modal").show();
formData.append("format", $("#format").val());
});
this.on('success', function(file, json) {
$(".busy-modal").hide();
alert(JSON.stringify(json));
});
this.on('addedfile', function(file) {
});
}
});
});
function ResetDropZone()
{
Dropzone.forElement("#file-dropzone").removeAllFiles(true);
}
</script>
这是我接收 JSON 响应数据的地方。
this.on('success', function(file, json) {
$(".busy-modal").hide();
alert(JSON.stringify(json));
});
我需要将此 json 对象传递给 AngularJS 控制器。我该怎么做?
【问题讨论】:
标签: javascript jquery angularjs json dropzone.js