Ask questionsChange the language of an existing editor
I am making a directive to help using Monaco Editor in AngularJS 1.X framework. One feature should be updating the language based on the option. But I cannot change the language.
It seems that the type of monacoeditor in my code is ICommonCodeEditor, I tried monacoeditor.updateOptions({ "language": newValues[key] }), it did nothing. I tried monacoeditor.getModel().updateOptions({ "language": newValues[key] }), it did nothing either. I tried also monacoeditor.setModelLanguage(monacoeditor.getModel(), newValues[key]), it gave an error TypeError: monacoeditor.setModelLanguage is not a function.
Note that it is not the problem of the directive, because it works well to change options like lineNumbers.
Could anyone help?
Answer questions
Symbolk
Anyone know how to change the language according to code file extension or first line like "#!/usr/bin/env python"?
Related questions