0

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?

5
  • are you using ui-ace ?
    – Rebornix
    Jun 3, 2015 at 7:11
  • yes I'm using ui-ace Jun 3, 2015 at 7:15
  • 1
    ui-ace might fail to trigger a digest loop to update ngModel. Try trigger a digest manually after you update the content, like $scope.evalAsync(function () { // you code here } ). Let me know if this works.
    – Rebornix
    Jun 3, 2015 at 7:26
  • Good man, thank you ... I put '$timeout' instead of 'evalAsync' and it worked perfect Jun 3, 2015 at 7:45
  • cool. I put my solution to answer below as it works.
    – Rebornix
    Jun 3, 2015 at 7:50

1 Answer 1

1

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");.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.