lundi 24 avril 2017

Model instance not sent via link-to to dynamic route if using RSVP.hash()

I can't seem to pass a model instance to a dynamic route if the dynamic route is model hash.

I have a companies route:

// routes/companies,js
export default Ember.Route.extend({
  model() {
    return this.get('store').findAll('company');
  }
});

And a companies/edit route:

// routes/companies/edit.js
export default Ember.Route.extend({
  model(params) {
    var store = this.store;
    return Ember.RSVP.hash({
      companies: store.findRecord('company', params.company_id),
      companyTypes: store.findAll('companyType')
    });
  }
});

My companies template is:

<!-- templates/companies.hbs -->
<div style="width:400px; height: 300px; overflow:true;float:left;">
  <h2>Companies</h2>

  
    <p>
      
      Edit
    </p>
  
  New
</div>


If I go directly to the dynamic route, all works fine.

However, in the link-to in companies.hbs I am passing the company model to the companies.edit route, but the data never gets to the companies.edit (company is undefined) I assume because companies.edit is expecting the model hash.




Aucun commentaire:

Enregistrer un commentaire