atularen / ngx-monaco-editor

Monaco Editor component for Angular 2 and Above
https://www.npmjs.com/package/ngx-monaco-editor
MIT License
428 stars 155 forks source link

Doubts about monaco.editor.create #231

Closed matheusnicolas closed 2 years ago

matheusnicolas commented 2 years ago

Hey guys, I'm trying to use monaco.editor.create and I'm facing this error:

Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')

how could I do this if I'm using ngx-monaco-editor and I want to configure my monaco-config.ts:

let editor = monaco.editor.create(document.getElementById('container'), { theme: 'my-theme', language: "my-language" });

My html angular code:

`

<ngx-monaco-editor class="editor custom--monaco-editor" *ngIf="!loading" [options]="editorOptions" [(ngModel)]="data.code">

`

I tried to use window.onload, addEventListener but nothing works, I don't know how could I try to solve this problem. I suspect it's something because I already have the ngx component in the html, but I might be wrong.

matheusnicolas commented 2 years ago

I got it working, no worries!

mike-luabase commented 2 years ago

@matheusnicolas what'd you change?