1

In ember I have a Model like this

App.IndexRoute = Ember.Route.extend({
  model: function() {
    return {
           model1: ['red', 'yellow', 'blue'],
      model2: [{color:'green'}]
    };
  }
});

In handlebars I can access the model 2 like

{{#each item in model2}}
<li>{{model2.color}}</li>
{{/each}}

How can I access model2 without using {{each}}?

When I use,

<li>{{model2.color}}</li>

it reurns no value, when I use

<li>{{model2}}</li> 

it shows [object Object] so how can I access model2 objects without using {{#each}}?

JsBin : http://emberjs.jsbin.com/tuvozuwa/6/edit Thanks

2
  • Since model2 seems to be an array, how about model2[0].color? Commented Oct 3, 2014 at 4:09
  • @FelixKling nope that seems to give an error the script breaks Commented Oct 3, 2014 at 4:12

1 Answer 1

2

I tried {{model2.[0].color}} and it worked in your context. (Note the dot (.) after model.)

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

Comments

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.