0
votes

I have returned data from server that contains page data that I am trying to use in a model. You can see the json here https://gist.github.com/bungdaddy/11152304. If you take a look at collection.template.data this is the data that I need in my model, which I have put together like so.

var PageTemplate = Ember.Object.extend();

PageTemplate.reopenClass({
    all: function(){
        return $.getJSON("http://myurl.com").then(function(response){
            var pageTemplate = [];

            var template = response.collection.template.data;

            template.forEach(function(data){
                pageTemplate.push(PageTemplate.create(data));
            });

            return pageTemplate;
        });
    }
});

export default PageTemplate;

This returns json, but my issue is, how in the template.hbs would I target an inner array like collection.template.data[10].acceptableValues? I could build a model just for this array, but I would like to have a PageTemplate with one call to the DB.

1

1 Answers

0
votes

If you are looking at a way to display

collection.template.data[10].acceptableValues

in your template, then all you need to do is set up a computed property on your model/controller that looks something like:

prop: function() {
  return this.get('collection.template.data').map(function(item) { 
               return item;});
}.property('collection.template.data')

Then in your handlebars you could just use

 {{#each prop}} 
 //blah
 {{each}}