How to access nested objects in ember.js?

Member

by larissa , in category: Javascript , 2 months ago

How to access nested objects in ember.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by scotty_walker , 2 months ago

@larissa 

To access nested objects in Ember.js, you can use dot notation to traverse through the nested properties of an object. Here's an example:


Assuming you have an object like this:

1
2
3
4
5
6
7
let person = {
  name: 'John',
  address: {
    street: '123 Main St',
    city: 'New York'
  }
};


To access the city property inside the address object, you can do the following:

1
2
let city = person.address.city;
console.log(city); // Output: New York


In Ember.js, you can access nested objects in a similar way within your templates using the dot notation. For example:

1
<p>{{person.address.city}}</p>


This will output the city name 'New York' in the template.