html:
<script src="~/Scripts/jquery-1.9.1.js"></script>
<script src="~/Scripts/DropZone-2.0.1.js"></script>
<script src="~/Scripts/angular.js"></script>
<script src="~/App_Angular/app.js"></script>
<div ng-app ="myApp" ng-controller ="ProductsCtrl">
<input ng-model="product.Name"/>
<input ng-model="product.PhotoName" id="result" />
<form id="dropzone" class="fade well">Drop files here</form>
<input type="button" value="Upload Files" ng-click="save(product)" />
Javascript:
$("#dropzone").dropzone({
url: 'Home/UploadFiles',
paramName: "files", // The name that will be used to transfer the file
maxFilesize: 102, // MB
enqueueForUpload: false,
accept: function (file, done) {
angular.element(document.getElementById('result')).scope()
.$apply(function (scope) {
scope.product.PhotoName = $('#result').val();
});
return done();
}
});
function uploadClicked() {
var dz = Dropzone.forElement("#dropzone");
for (var i = 0; i < dz.files.length; i++) {
dz.filesQueue.push(dz.files[i]);
}
dz.processQueue(dz);
$('#innerQue').empty();
}
当在 ng-click 中调用 save 方法时,我已经能够成功地将照片名称传递给 $scope.product.PhotoName。
我无法上传图片。我不知道如何从角度调用“uploadClicked”。
任何援助将不胜感激。