ngstack / code-editor

Code editor component for Angular applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updating value later on

fitness23 opened this issue · comments

The current system is fine if we know what the initial value is.
However when we get data from an api and wish to update the model's value this doesn't work.

I tried this.codeModel.value = "alert('This is the new code from the api');";

But this doesn't work, the editor still shows the original value. Please could this feature be added?

Ah I got it. For anyone stumped with this problem, you need to declare the entire object again. For example after your api has loaded:

this.codeModel = {
                            language: 'javascript',
                            value: this.myForm.controls.code['controls'].create.value,
                          };

Ok, closing as you have found the solution.