ui-ace
ui-ace copied to clipboard
setValue() doesn't work
editor:
<div ng-model="html" ui-ace="{
require: ['ace/ext/language_tools'],
advanced: {
enableEmmet:true,
enableSnippets: false,
},
useWrapMode : true,
fontSize: '14px',
splitMode : false,
showGutter: true,
theme:'monokai',
mode: 'html',
firstLineNumber: 5,
onLoad: aceLoaded,
onChange: bodyChanged
}">
tried:
$scope.aceLoaded = function(_editor) {
var _session = _editor.getSession();
_session.setValue('hello');
};
and:
$scope.aceLoaded = function(_editor) {
_editor.setValue('hello');
};
Expect this everything works nice, thanks!
+1 facing the same issue
Use ngModel for it.
$scope.aceLoaded = function($editor) {
$scope.$editor = $editor;
};
$scope.onOpen = function(code, fileExtension) {
let mode = resolveExtension(fileExtension);
$scope.html = code;
$scope.$editor.session.setMode('ace/mode/' + mode);
}