我在angularjs应用程序中使用UI-codemirror进行java代码编辑,模式设置为'text / x-java'。现在我想使用自动完成和lint这样的插件。
自动完成我使用keyup和onKeyUp设置如下选项,两个事件都不会被触发。
在控制器中配置选项:
_this.editorOptions = {
lineWrapping: true,
lineNumbers: true,
mode: 'text/x-java',
smartIndent: true,
tabSize: 4,
indentWithTabs: true,
tabindex: 4,
autofocus: true,
addModeClass: true,
keyup: function (e, s) {
console.log("Event Keyup");
},
onKeyUp: function (e, s) {
console.log("Event Keyup");
}
}
模板中的指令:
<ui-codemirror ui-codemirror-opts="vm.editorOptions" ng-model="vm.activeQuestion.candidateAnswer"></ui-codemirror>
要包含哪些addon js脚本以及要为锻炼设置哪些配置选项?
答案 0 :(得分:0)
访问编辑器;之后你可以注册一个监听器:
var myCodeMirror = CodeMirror.fromTextArea(myTextArea);
myCodeMirror.on('change', function(codemirrorinstance)
{
console.log(key pressed);
})