Angular 2 pipe that transforms JSON object to pretty-printed JSON

前端 未结 4 1643
清酒与你
清酒与你 2020-12-02 15:01

Trying to write an Angular 2 pipe that will take a JSON object string and return it pretty-printed/formatted to display to the user.

For example, it would take this:

4条回答
  •  感情败类
    2020-12-02 15:49

    since my variable is two way binded with ngModel, I could not do it on html. I used on component side JSON.stringify(displayValue, null, 2) and it did the job.

提交回复
热议问题