2016-08-24 67 views
0

這是我的代碼如何在IIS Server中爲Ace Editor加載ace/mode/javascript和theme js文件?

var app = angular.module('editorApp', ['ui.ace']); 
 
app.controller('appCtrl', function($scope){ 
 
    window.define = ace.define; 
 
    $scope.aceOptions = { 
 
      workerPath: '../../Scripts/app/vendor/',  
 
      useWrapMode: true, 
 
      showGutter: true, 
 
      theme: 'chrome', 
 
      firstLineNumber: 1, 
 
      onLoad: function (_editor) { 
 
       $scope.onLoadSaveCode = ""; 
 
       var _session = _editor.getSession(); 
 
       _session.setMode('ace/mode/javascript'); 
 
       var _renderer = _editor.renderer; 
 

 
       _session.on('changeAnnotation', function() { 
 
        $scope.annotations = []; 
 
        $scope.annotations = _editor.getSession().getAnnotations(); 
 
       }), 
 
       _editor.$blockScrolling = Infinity; 
 
       // Editor Events 
 
       var shouldRevert = false; 
 
       _session.on("change", function (e) { 
 
        var currentValue = _editor.getSession().getValue(); 
 
        $scope.clientScriptFunction.json_meta_data = currentValue; 
 
       }); 
 
      }, 
 
      require: ['ace/ext/language_tools'], 
 
      advanced: { 
 
       enableSnippets: false, 
 
       enableBasicAutocompletion: true, 
 
       enableLiveAutocompletion: true 
 
      } 
 
     }; 
 
});
<div class="e1" ui-ace="aceOptions"> 
 
    
 
    </div>

BundleConfig.cs: -

bundles.Add(new ScriptBundle("~/bundles/scripts/dashboard").Include(
      "~/Scripts/app/vendor/angular.min.js", 
      "~/Scripts/app/vendor/angular-sanitize.js",     
      "~/Scripts/app/vendor/ace.js",  
      "~/Scripts/app/vendor/ui-ace.min.js", 
      "~/Scripts/app/vendor/ext-language_tools.js", 
      "~/Scripts/app/vendor/angular-animate.js", 
      "~/Scripts/app/vendor/angular.ui-router.min.js", 
      "~/Scripts/app/dashboard/app.js" 
     )); 

在上面的代碼在本地進行加工。當我將代碼發佈到IIS服務器並運行該項目時。出現兩個錯誤Failed to load Resources theme-chrome.js and mode-javascript.js files。我試圖創建ace文件夾放置這兩個文件,但也提出了相同的問題,所以如何解決錯誤,如何加載這些文件。

回答

1

最後我得到了答案。 捆綁這兩個模式-javascript和theme-chrome js文件。然後定義這兩個文件中的定義,如打開模式 - javascript和theme-chrome js文件而不是define(使用ace.deine(