1

In my component i am getting the json in the variable name peopleDetails

Sample JSON:

{
   name:'xxxx',
   age:123,
   details:{
      qualification:'abc',
      yearofPassing:1111
   }
}

I tried to display it in my html like this

<div>{{peopleDetails.name | async}}

But i cant able to get the property of the json

It is printing the whole json when i tried like this.

<div>{{peopleDetails.name | async | json}}

But i want to access all the properties of the Json.

3
  • Why are you using | async? Commented Mar 1, 2017 at 6:07
  • Because i am selecting it from the store Commented Mar 1, 2017 at 6:12
  • It's not valid JSON, it should be { name:'xxxx', age:123, details:{ qualification:'abc', yearofPassing:1111 } } Commented Mar 1, 2017 at 6:13

1 Answer 1

3

Hard to tell from your question what the problem is. A guess:

<div>{{(peopleDetails | async)?.name}} </div>
Sign up to request clarification or add additional context in comments.

2 Comments

Can you explain me why we are accessing with question mark
To prevent an error when (peopleDetails | async) returns null, because null doesn't have a name property angular.io/docs/ts/latest/guide/…

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.