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