简体   繁体   中英

UI-codemirror Addons

I am using UI-codemirror in angularjs application for java code editing with mode set to 'text/x-java'. Now I want to use addons like autocomplete and lint.

for autocomplete I set options as below with keyup and also with onKeyUp, both the events are not triggered.

configure options in controller:

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

        }
    }

Directive in the template:

<ui-codemirror ui-codemirror-opts="vm.editorOptions" ng-model="vm.activeQuestion.candidateAnswer"></ui-codemirror>

What are the addon js scripts to include and what configuration options to set for these to workout?

Get access to the editor; after that you can register a listener on it :

var myCodeMirror = CodeMirror.fromTextArea(myTextArea);
myCodeMirror.on('change', function(codemirrorinstance)
{
    console.log(key pressed);
})

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