Akshay Verma
Akshay Verma

Reputation: 31

how to display the element after parsing json in angular template?

Here is the code

{{payment.metadata | json}}

This is what i am gettting

"{\"phoneNumber\":\"4163000477\",\"animalName\":\"Mustang\"}"

How to display the phone number? I have tried accessing it by this {{(payment.metadata | json).phoneNumber}}

Upvotes: 1

Views: 42

Answers (1)

Maxim Kasyanov
Maxim Kasyanov

Reputation: 1058

When you get this json use JSON.parse(json). This method covert string to object. After that you could access to the field.

 let example = JSON.parse(YOUR_JSON);

HTML part:

{{ example.phoneNumber }}

Upvotes: 1

Related Questions