Question

My code looks like :

$scope.aceIDEs='var hw = new function() {\n  console.log("Hello world!");\n}'

$scope.loadAceJSExample = function (_editor) {
_editor.setValue($scope.aceIDEs);
_editor.getSession().setUseWorker(false);
_editor.setHighlightActiveLine(true);
};

And:

<div class="container fade-in" style='padding: 4em;'>
<div>
      ui-ace="{onLoad : loadAceJSExample,
      onChange : aceJSExampleChanged,
      useWrapMode : true,
      theme : 'github',
      showGutter: true,
      mode: 'javascript'

    }" />

I tried calling _editor.getSession().removeMarker(); but did not help

Every time i refresh it looks like this,once i click in it returns to normal: Before i click

Was it helpful?

Solution

Use _editor.session.setValue($scope.aceIDEs); which also resets undomanager. Alternatively you can use _editor.setValue($scope.aceIDEs, cursorPos);. where cursorPos=-1 puts cursor at start and cursorPos=1 at the end. Or call _editor.clearSelection() after setting value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top