How to convert an object to JSON correctly in Angular 2 with TypeScript

前端 未结 5 1099
灰色年华
灰色年华 2020-12-23 13:40

I\'m creating an Angular 2 simple CRUD application that allows me to CRUD products. I\'m trying to implement the post method so I can create a product. My backend is an ASP.

5条回答
  •  时光说笑
    2020-12-23 14:04

    If you are solely interested in outputting the JSON somewhere in your HTML, you could also use a pipe inside an interpolation. For example:

    {{ product | json }}

    I am not entirely sure it works for every AngularJS version, but it works perfectly in my Ionic App (which uses Angular 2+).

提交回复
热议问题