0

我已經在IE的舊版本中看到很多關於plupload和模式對話框的文章,但其中任何一個都有我的問題的解決方案。我正在使用AngularJS UI來打開包含plupload的容器div的模塊,我需要以這種方式來完成這項工作。Plupload + AngularJS UI模式在IE中不起作用

我試過所有的解決方案:uploader.refresh(),我已經使用require.js加載plupload腳本時,對話框已打開,但我還沒有找到一個工程。

這裏的調用模式對話框控制器的功能:

$scope.EnviarNovoAnexoClick = function() { 
     var modalInstance = $modal.open({ 
      templateUrl: '/Dialog/EnviarAnexo', 
      controller: 'EnviarAnexoDialogController', 
      resolve: { 
       documentoId: function() { 
        return $scope.documentoId; 
       }      
      } 
     }); 

     modalInstance.result.then(function (anexo) { 
      $scope.documento.anexos.push(anexo); 
     }, function() {//dismiss callback 
     }); 
    } 

下面是調用上傳功能:

require(["/Scripts/plupload.full.js"], function (util) { 
     $scope.anexoUploader = new plupload.Uploader({ 
      runtimes: 'gears,html5,flash,silverlight,browserplus,html4', 
      browse_button: 'anexoBtUpload', 
      container: 'anexoUploadDiv', 
      unique_names: true, 
      multi_selection: false, 
      max_file_size: '150mb', 
      chunk_size: '64kb', 
      url: '/Documento/Upload', 
      flash_swf_url: '/Scripts/plupload.flash.swf', 
      silverlight_xap_url: '/Scripts/plupload.silverlight.xap', 
      resize: { width: 320, height: 240, quality: 90 }, 
      filters: [ 
        { title: "PDFs ", extensions: "pdf" }, 
        { title: "Imagens", extensions: "jpg,gif,png" }, 
        { title: "Zips", extensions: "zip" }, 
        { title: "Todos", extensions: "*" } 
      ], 
      init: { 
       FilesAdded: function (up, files) { 
        if ($scope.uploadDocumento == null) { 
         $scope.showOrigemAnexo = false; 
         $scope.novoAnexo.upload = {}; 
         $scope.InicializaUpload($scope.novoAnexo.upload); 
         $scope.uploadDocumento = $scope.novoAnexo.upload; 
        } 

        var fileName = $scope.anexoUploader.files[$scope.anexoUploader.files.length - 1].name; 

        $scope.uploadDocumento.nome = fileName; 
        $scope.novoAnexo.descricao = dotlessName(fileName); 
        $scope.$apply(); 

        up.refresh(); // Reposition Flash/Silverlight 
        up.start(); 
       }, 
       UploadProgress: function (up, file) { 
        $scope.uploadDocumento.size = file.size; 
        $scope.uploadDocumento.percentage = file.percent; 
        $scope.$apply(); 
       }, 
       FileUploaded: function (up, file, response) { 
        $scope.uploadDocumento.id = file.id; 
        $scope.uploadDocumento.size = file.size; 
        $scope.$apply(); 
       } 
      } 
     }); 

     $scope.anexoUploader.init(); 
    }); 

文件對話框將在Chrome中,IE10和Firefox打開,但我需要它可以在IE9和8上工作。

謝謝(:

回答

0

這與緩存和動態加載的腳本標記有關。

解決方案,爲我工作:

加入這個指令:

.directive('cachedTemplate', ['$templateCache', function ($templateCache) { 
    "use strict"; 
    return { 
    restrict: 'A', 
    terminal: true, 
    compile: function (element, attr) { 
     if (attr.type === 'text/ng-template') { 
     var templateUrl = attr.cachedTemplate, 
      text = element.html(); 
     $templateCache.put(templateUrl, text); 
     } 
    } 
    }; 
}]) 

聲明你的語氣內容

<div data-cached-template="myInnerModalContent.html" type="text/ng-template"> 
    <!-- content --> 
</div> 

您可能需要這種風格,以及:

*[type="text/ng-template"]{ 
    display: none; 
} 

在控制器:

$scope.open = function() { 
      var modalInstance = $modal.open({ 
       templateUrl: 'ModalContent.html', 
       controller: modalInstanceCtrl 
      }); 
     }; 

參考:http://blog.tomaszbialecki.info/ie8-angularjs-script-cache-problem/

相關問題