【发布时间】:2017-03-20 16:51:36
【问题描述】:
我在 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>
要包含哪些插件 js 脚本以及为这些脚本设置哪些配置选项以进行锻炼?
【问题讨论】:
-
您使用的是 Codemirror 指令对吗?如果您使用的是指令,那么您的代码不正确。 github.com/angular-ui/ui-codemirror
-
是的,我只在链接中实现了。编辑了我的问题以详细展示我的实现。
-
你可以看到一个例子来检查事件:- _editor.on("change", function(){ ... });
标签: angularjs codemirror ui-codemirror