编程语言
首页 > 编程语言> > javascript-使用angular-ui-ace时看不到ace编辑器

javascript-使用angular-ui-ace时看不到ace编辑器

作者:互联网

我正在尝试在我的使用angular-ui-ace的nodejs应用程序中使用ace编辑器.即使我在html中填写了div,也无法在屏幕上看到ace编辑器.
我正在按照这里的指示:ui-ace

index.html:

 <script src="bower_components/angular-route/angular-route.js"></script>
  <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
  <script type="text/javascript" src="bower_components/ace-builds/src-min-noconflict/ace.js"></script> 
  <script type="text/javascript" src="bower_components/ace-builds/src-min-noconflict/ext-language_tools.js"></script>
  <script type="text/javascript" src="bower_components/angular-ui-ace/ui-ace.js"></script>
     ...
     ...
    <!-- build:js({.tmp,client}) app/app.js -->
    <script src="app/app.js"></script>
      <!-- injector:js -->
      <script src="app/main/main.controller.js"></script>
      <script src="app/main/main.js"></script>

app.js:

'use strict';

angular.module('plsdiffApp', [
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ngRoute',
  'btford.socket-io',
  'ui.ace',
  'ui.bootstrap'
])

main.html:

<form>
  ...
  <div>
    <div ui-ace="{ onl oad : aceLoaded, workerPath:'bower_components/ace/lib/'}">               </div>
</form>

main.less:

.ace_editor { height: 200px; }

main.controller.js:

     $scope.aceLoaded = function(_editor){
    // Editor part
    var _session = _editor.getSession();
    var _renderer = _editor.renderer;
    alert('inside aceLoaded');
    // Options
    _editor.setReadOnly(true);
    _session.setUndoManager(new ace.UndoManager());
    _renderer.setShowGutter(false);
    _session.setValue('<?xml version="1.0" encoding="UTF-8"?><dummy_xml id="1"></dummy_xml>');

    // Events
    _editor.on("changeSession", function(){ alert('changeSession'); });
    _session.on("change", function(){alert('change');});
  };

呈现的html:

<div class=" ace_editor ace-tm" ui-ace="{ onl oad : aceLoaded, workerPath:'bower_components/ace/lib/'}">
<textarea class="ace_text-input" wrap="off" spellcheck="false" style="opacity: 0;"></textarea>
<div class="ace_gutter" style="display: none;">
<div class="ace_scroller" style="left: 0px; right: 0px; bottom: 0px;">
<div class="ace_scrollbar ace_scrollbar-v" style="display: none; width: 20px; bottom: 0px;">
<div class="ace_scrollbar ace_scrollbar-h" style="display: none; height: 20px; left: 0px; right: 0px;">
<div style="height: auto; width: auto; top: -100px; left: -100px; visibility: hidden; position: fixed; white-space: pre; font: inherit; overflow: hidden;">
</div>

但我根本看不到Ace编辑器.我究竟做错了什么?

谢谢.

解决方法:

正确的答案是这样.

为了看到一些东西,最好添加一些CSS,例如

.ace_editor {高度:200px; }

除非您设置此CSS,否则您将无法看到编辑器

标签:ace-editor,angularjs,node-js,css,javascript
来源: https://codeday.me/bug/20191120/2045572.html