我在网站上使用 Inspinia 管理主题。我在其中一个使用 dropzone js 的 ui 引导角度选项卡上。我使用了一个自定义指令,并在我希望成功更新当前选项卡的控制器上。即使角度变量更新正确,我也需要单击选项卡上的某个位置以显示新值。
html
<tabset>
<tab heading="Tab 1" ng-attr-active="vm.tabs[0].active">
<div class="panel-body col-sm-12">
<div ng-if="!vm.isResultsLoaded">
<form class="dropzone" drop-zone="dropzoneConfig" id="dropzone">
<button id="submitFile" ng-click="vm.update()" type="submit" class="btn btn-primary pull-right">Submit this form!</button>
</form>
</div>
<div class="table-responsive" ng-if="vm.isResultsLoaded">
<button class="btn btn-primary" ng-click="vm.switchToUpload()" type="submit">Ladda mer filer</button>
<table class="table">
...
</table>
</div>
</div>
</tab>
</tabset>
指示
function dropZone() {
return function (scope, element, attrs) {
var config = scope[attrs.dropZone];
// create a Dropzone for the element with the given options
var dropzone = new Dropzone(element[0], config.options);
// bind the given event handlers
angular.forEach(config.eventHandlers, function (handler, event) {
dropzone.on(event, handler);
});
};
}
控制器
function tabListController(uploadService, $state, $scope) {
...
$scope.dropzoneConfig = {
"options": {
"url": "/api/system/fileupload",
"method": "post",
"autoProcessQueue": false
},
"eventHandlers": {
"addedfile": function (file, xhr, formData) {
var myDropzone = this;
$('#submitFile').click(function () {
myDropzone.processQueue();
});
},
"success": function (file, data) {
vm.results = data;
vm.isResultsLoaded = true;
}
}
};
}
有什么想法我应该做些什么来解决它?