1
我在網站上使用Inspinia管理主題。我有其中一個使用dropzone js的引導程序角標籤。我使用了一個自定義指令,並在我想成功更新當前選項卡的控制器上。即使角度變量更新正確,我需要點擊標籤上的某處來顯示新值。成功更新dropzone上的角度js上的選項卡
的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;
}
}
};
}
任何想法,我應該怎麼做來解決它?
非常感謝!那麼我已經發現這個$範圍。$申請較早,但由於某種原因$應用程序在Chrome控制檯上拋出一個錯誤。現在ti工作正常!花了相當一段時間! – Agraell
你的時機非常完美。我昨天晚上也遇到了這個特殊的問題(與Dropzone一樣)。 :) –
Dropzone已經讓我對角度感到困惑了很多。如果您使用的是Inspinia,則該指令非常糟糕,因爲它干預並且不允許在控制器中進行自定義設置。我從別的地方找到了這個控制器,它的功能就像一個魅力。 – Agraell