import ... declare var monaco: any; @Component({ selector: 'app-monaco-editor', templateUrl: './monaco-editor.component.html', styleUrls: ['./monaco-editor.component.scss'], }) export class MonacoEditorComponent implements OnInit, OnDestroy, AfterViewInit { public _editor: any; @ViewChild('editorContainer', { static: true }) _editorContainer: ElementRef; private initMonaco(): void { if(!this.monacoEditorService.loaded) { this.monacoEditorService.loadingFinished.pipe(first()).subscribe(() => { this.initMonaco(); }); return; } this._editor = monaco.editor.create( this._editorContainer.nativeElement, options ); } ngAfterViewInit(): void { this.initMonaco(); }