1

I am new to angular 2. How do I get nested data from JSON into my Template?

Here's my JSON:

[
    {
        "eId" : "1",
        "name":"Jimi Hendrix", 
        "designation":"UI Developer", 
        "profileImage":"../defaultDP.jpeg", 
        "skills":"HTML, CSS, JS, jQuery, AngularJS, XML", 
        "graph" : {
            "keys" : ["HTML, JS, jQuery, AngularJS"],
            "values" : ["8, 5, 8, 6"]
        }
    }

]

And in my template when I am trying to access name, eId I can access easily. e.g,

{{JSONDummyData.eId}} {{JSONDummyData.name}}

but when I am trying to get Nested values, e.g,

{{JSONDummyData.graph.values}}

I am not able to access this. thanks in advance!

1 Answer 1

1

Since keys and values are arrays, you have to specify which element you want to display exactly like so for instance:

{{ JSONDummyData.graph.values[0] }}

working Plunker for example usage

Sign up to request clarification or add additional context in comments.

3 Comments

Then your object does not have the structure you posted.
Its the same one. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.