Glenn Utter Glenn Utter - 3 months ago 20x
JSON Question

Angular 2: Access object data

In my Angular RC2 app I make an observable HTTP call that returns the following JSON to me from the API:

"Type": 1

I map the data like this:

(data) => {
this.details = data.Details;
this.type = data.Type;
(error) => {

How do I access the values inside the "Details" object from here?

I tried:


But that won't work and I can't use ngFor to loop it either.


You could use the Elvis operator for this:


As a matter of fact, you load your data asynchronously so details is undefined at the beginning.