4
我使用這個指令來渲染Dropzone.js
頁文件:如何顯示已存儲在服務器懸浮窗中Angularjs
angular.module('dropzone', []).directive('dropzone', function() {
return function (scope, element, attrs) {
var config, dropzone;
config = scope[attrs.dropzone];
// create a Dropzone for the element with the given options
dropzone = new Dropzone(element[0], config.options);
// bind the given event handlers
angular.forEach(config.eventHandlers, function (handler, event) {
dropzone.on(event, handler);
});
};
});
,並在我的控制器使用此代碼:
angular.module('app', ['dropzone']);
angular.module('app').controller('SomeCtrl', function ($scope) {
$scope.dropzoneConfig = {
'options': { // passed into the Dropzone constructor
'url': 'upload.php'
},
'eventHandlers': {
'sending': function (file, xhr, formData) {
},
'success': function (file, response) {
}
}
};
});
在懸浮窗來顯示已存儲在服務器上的文件使用mockFile
和this.emit
。現在如何獲得this
並運行emit
函數?
你是個天才 – Sytham