2015-09-23 140 views
2

我正在使用aungular-ui-ace在我的網站中創建代碼編輯器。一切都很好,但我想包括自動完成選項。選項{enableBasicAutocompletion:true}不爲我工作。如何在編輯器中使用angular-ui-ace添加自動完成選項

我的代碼:

var app = angular.module('MyApp', ['ui.ace']); 
 

 
app.controller('MyCtrl', function($scope){});
<head> 
 
    <script src="/bower_components/angular/angular.js"></script> 
 
    <script type="text/javascript" src="/bower_components/ace-builds/src-min-noconflict/ace.js"></script> 
 
    <script type="text/javascript" src="/bower_components/angular-ui-ace/ui-ace.js"></script> 
 
</head> 
 

 
<body ng-app="MyApp" ng-controller="MyCtrl"> 
 
    <div ui-ace="{mode: 'javascript', enableBasicAutocompletion: true}"></div> 
 
</body>

回答

2

請參閱自述https://github.com/angular-ui/ui-ace#advanced-options

var app = angular.module('MyApp', ['ui.ace']); 
 

 
app.controller('MyCtrl', function($scope){});
<head> 
 
    <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.js"></script>--> 
 
    <script src="http://angular-ui.github.io/ui-ace/assets/vendor/angular.min.js"></script> 
 
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/ace.js"></script> 
 
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/ext-language_tools.js"></script> 
 
    <script type="text/javascript" src="http://angular-ui.github.io/ui-ace/dist/ui-ace.js"></script> 
 
</head> 
 

 
<style> 
 
.ace_editor { 
 
    height : 200px; 
 
} 
 
</style> 
 

 
<body ng-app="MyApp" ng-controller="MyCtrl"> 
 
    <div ui-ace="{mode: 'javascript', 
 
    require: ['ace/ext/language_tools'], 
 
    advanced: { 
 
     enableSnippets: true, 
 
     enableBasicAutocompletion: true, 
 
     enableLiveAutocompletion: true 
 
    }}"></div> 
 
</body>

的高級選項部分
相關問題