这是我的 Controller 代码
$scope.aceOptions = {
workerPath: 'http://localhost:50871/Scripts/app/vendor/',
useWrapMode: true,
showGutter: true,
theme: 'chrome',
firstLineNumber: 1,
onLoad: function (_editor) {
$scope.script = {};
$scope.script.scriptCode = "function fieldName_columnName_" + "functionName(){\n\n\n}";
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;
_session.on("change", function (e) {
var currentValue = _editor.getSession().getValue();
$scope.script.scriptCode = currentValue;
});
},
require: ['ace/ext/language_tools'],
advanced: {
enableSnippets: true,
enableBasicAutocompletion: true,
enableLiveAutocompletion: true
}
}
我为 ui-ace 写了指令这是我的 html 代码
<javascript-editor code="script.scriptCode" ace-option="aceOptions"></javascript-editor>
指令代码是
SCSApp
.directive('javascriptEditor', [
function () {
return {
restrict: 'E',
scope: {
data: '=code',
aceOption: '='
},
templateUrl: '/Scripts/app/shared/directives/javascripEditor/partials/javascriptEditor.html',
link: function (scope, element, attrs) {
}
}
}]);
这是我的 javascriptEditor.html
<div class="e1" ui-ace="aceOption" ng-model="data"></div>
我只是想限制用户在 ui-ace 编辑器中不能写一个以上的 javascript 函数
最佳答案
关于javascript - 如何限制用户在 ui-ace 编辑器中只写一个 javascript 函数(方法),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34259683/