Gan
Gan

Reputation: 164

Handlebars - Backbone Access nested attributes

Lets consider I have a model with the following nested structure:

article
 >title
 >id
 >related //which is an array lets say of a size n
  >related[0]
  >related[1]
   >title
   >id

Is there a way to access each title of the related array by handlebars?

Thanks :)

Upvotes: 0

Views: 161

Answers (1)

T Nguyen
T Nguyen

Reputation: 3415

Sure. If you're just looking for a single value then it's just {{article.related.[n].title}}. If you're looking to iterate through them and make a table or something, then you could do:

{{#each article.related}}
    {{title}} / {{id}}
{{/each}}

Upvotes: 1

Related Questions