2016-08-24 64 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(