【发布时间】:2019-01-31 06:50:34
【问题描述】:
我正在使用 ace 编辑器开发 angularJs。
每次我在屏幕上更改光标位置时,我都想获取光标位置。
问题是,我总是得到光标的初始位置,而不是最新位置。
下面是我的代码:
this.editorOptions = {
mode: 'groovy',
theme: 'textmate',
showGutter: true, // Enabling line numbers for the editor
useWrapMode: true,
showPrintMargin: false, // Disabling print margin line from the editor
onLoad: (editor) => { // Triggered when the editor gets loaded (i.e., on initial load of the editor)
this.policyEditorBox = editor;
},
onChange: (editor) => { // Triggered on content change of the editor
this.policyEditorBox = editor[1];
console.log("policy editor:",this.policyEditorBox);
console.log(editor[1].selection.cursor.row); //this line always print zero (initial position)
}
};
【问题讨论】:
标签: angularjs ace-editor