diff --git a/components/code-editor/nz-code-editor.component.ts b/components/code-editor/nz-code-editor.component.ts index 891b25e46b..6175fa6281 100644 --- a/components/code-editor/nz-code-editor.component.ts +++ b/components/code-editor/nz-code-editor.component.ts @@ -99,7 +99,9 @@ export class NzCodeEditorComponent implements OnDestroy, AfterViewInit { } ngOnDestroy(): void { - this.editorInstance.dispose(); + if (this.editorInstance) { + this.editorInstance.dispose(); + } this.destroy$.next(); this.destroy$.complete();