简体   繁体   English

如何使用angular2或typescript使编辑器文本获取与json数据相同的数据

[英]how to make the editor text to get the data same as json data using angular2 or typescript

i have a json data but when it is assigned to the editor it is missing the quotes, so can anyone help me how to get the quotes also to the editor. 我有一个json数据,但是当它分配给编辑器时,它缺少引号,因此任何人都可以帮助我如何将引号也发送给编辑器。

ts code: ts代码:

this.product
      .getproduct(t)
      .subscribe(
        products => {
          let editorOptions = {
            showJSONEditorTab: true
          };
        }),

  }

Here im getting the console.log(this.survey_val) output like this: 这里我正在获取console.log(this.survey_val)输出,如下所示:

{"pages":[{"name":"page1"]} 

console.log(this.editor.text); console.log(this.editor.text);

   {
 pages: [
  {
   name: "page1",
     ]
    }

I got it working by giving, 我付出了努力,

let editorOptions = {
            showJSONEditorTab: true, generateValidJSON : true
          };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM