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

前端 未结 4 1614
清酒与你
清酒与你 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条回答
  •  -上瘾入骨i
    2020-12-02 15:51

    I would like to add an even simpler way to do this, using the built-in json pipe:

    {{data | json}}

    This way, the formatting is preserved.

提交回复
热议问题