在<pre> tag to the variable

时间:2018-02-05 12:49:28

标签: html angular typescript

I display JSON in pre tag using json pipe. Unfortunately when I edit JSON I don't see changes in value variable so how can I bind these values?

<pre contenteditable="true">{{value | json}}</pre>

2 个答案:

答案 0 :(得分:1)

MAybe have you tried something like:

<input type="text" col="5" [(NgModel)]="value" />

<pre contenteditable="true">{{value | json}}</pre>

So put your json in a text area with a bind on your value?

Hope it helps you!!

答案 1 :(得分:0)

我使用<textarea>代替<pre>,它解决了我的问题:)