Search code examples
angularjsace-editor

Ace editor replace text


I'm using ui-ace, I succeed to replace the selection text as the following:

$ace_editor.session.replace($ace_editor.selection.getRange(), "Hii");

But my problem is that this way don't update the ng-model, did I forget something to do?


Solution

  • ui-ace will not update your the model for you then you need to trigger a digest loop yourself once you update the content in the editor.

    A proper solution is use evalAsync() or $timeout() to wrap $ace_editor.session.replace($ace_editor.selection.getRange(), "Hii");.