Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language change not reflecting in editor #54

Closed
rajatkhare619 opened this issue May 15, 2018 · 2 comments
Closed

Language change not reflecting in editor #54

rajatkhare619 opened this issue May 15, 2018 · 2 comments

Comments

@rajatkhare619
Copy link

I added the editor on the HTML like this:

<ngx-monaco-editor [options]="editorOptions"></ngx-monaco-editor>

Initially, the options are set to the following object in the component:

editorOptions = {theme: 'vs-dark', language: 'javascript'};

I am trying to update the editor's language by changing the 'language' property in the options like this:
I created a button and set up a click event handler on it:

<button (click)="setHTML()>Set language to HTML</button>

setHTML() {
this.editorOptions.language = 'html';
  }

I thought this would change the language in the editor as the options should be bound two way but when I type HTML in the editor, there is no intellisense.

What am I doing wrong?
Is there another way to achieve this?

@rajatkhare619
Copy link
Author

rajatkhare619 commented May 15, 2018

Never mind.
Got the answer here (Line 73)
But I'm interested in knowing why my earlier code was not working.

@atu1kr
Copy link
Contributor

atu1kr commented May 15, 2018

Editor is re-initialized when options are updated. As angular @Input setter detects only object updates only. So property updates are not handled.

@atu1kr atu1kr closed this as completed May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants