I have a model with hasMany relationship:
App.Offer = DS.Model.extend({
shop: DS.attr('number'), //ext key
name: DS.attr('string'),
description: DS.attr('number'),
products: DS.hasMany('product', {embedded: true})
});
App.Product = DS.Model.extend({
name: DS.attr('string'),
description: DS.attr('string'),
});
The record are sideloaded by the server and if I use them in templates it works:
{{#each product in model.products}}
<li>{{product.nome}} - {{product.descrizione}}</li>
{{/each}}
But what if I want load the products into an array in the controller?
actions: {
var products = [];
$.each(this.get('model').get('products'), function(index, value) {
products[index] = value.get('nome'); //this doesn't work
});
}