简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM