Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/codemirror.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
forwardRef,
AfterViewInit,
OnDestroy,
NgZone
} from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import * as CodeMirror from 'codemirror';
Expand Down Expand Up @@ -46,7 +47,7 @@ export class CodemirrorComponent implements AfterViewInit, OnDestroy {
/**
* Constructor
*/
constructor() {}
constructor(private _zone: NgZone) {}

get value() { return this._value; }

Expand Down Expand Up @@ -76,8 +77,10 @@ export class CodemirrorComponent implements AfterViewInit, OnDestroy {
* Initialize codemirror
*/
codemirrorInit(config) {
this.instance = CodeMirror.fromTextArea(this.host.nativeElement, config);
this.instance.setValue(this._value);
this._zone.runOutsideAngular(() => {
this.instance = CodeMirror.fromTextArea(this.host.nativeElement, config);
this.instance.setValue(this._value);
});

this.instance.on('change', () => {
this.updateValue(this.instance.getValue());
Expand Down