handlebars.js - Ember.js - Cannot render nested models -
have upcoming weekend project , using evaluate ember.js , cannot figure out why cannot display nested objects in template. not work:
{{#each emails}} {{email_address}} {{/each}} when try {{emails}} hint right:
models:
app.contact = ds.model.extend({ firstname: ds.attr('string'), lastname: ds.attr('string'), company: ds.attr('string'), emails: ds.hasmany('app.email') }); app.email = ds.model.extend({ contact: ds.belongsto('app.contact'), emailaddress: ds.attr('string'), }); route:
app.router.map(function() { this.resource('contacts', function() { this.resource('contact', {path: ':contact_id'}); }); }); app.contactsroute = ember.route.extend({ init: function() {}, model: function() { return app.contact.find(); } }); app.contactroute = ember.route.extend({ model: function(params) { return app.contact.find(params.contact_id); } }); i have no idea try next. i'm using active_model_serializer in rails. i've tried embedding, side-loading no avail. i'm sure it's simple i'm missing.thanks in advance!
when using each helper it's recomendable more specific items looping on avoid such problems.
try following:
{{#each email in model.emails}} {{email.emailaddress}} {{/each}} this should work:
{{#each emails}} {{this.emailaddress}} {{/each}} and also, model property called emailaddress , not email_address.
hope helps.
Comments
Post a Comment