I am trying to link codemirror with Angular 2 (TypeScript) . Right now ,I am able to display CodeEditor using a codearea custom directive ,which dynamically loads a script file
I use it a little bit differently but maybe it will help you. Basiaclly in ngAfterViewInit I create code mirror instance using elementRef:
this.cm = CodeMirror(this.elementRef.nativeElement, options);
then in the onChange event:
this.cm.on('change', (editor: CodeMirror.Editor) => {
editor.getDoc().getValue();
});
If you don't want to use onChange, you can always get the value from code mirror instance, eg.
cmInstance.getEditor().getDoc().getValue()