this is my controller code
$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 } }
I wrote a directive for ui-ace, this is my html code
<javascript-editor code="script.scriptCode" ace-option="aceOptions"></javascript-editor>
and directory code
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) { } } }]);
and this is my javascriptEditor.html
<div class="e1" ui-ace="aceOption" ng-model="data"></div>
I just want to restrict the user from writing more than one javascript function in the ui-ace editor