Ember 2.6, how to pass model in render template

Hi, I want to render template from action. Here is an example of my code.

export default Ember.Route.extend({
actions: {
execute(){

  let results = this.store.findAll('results');
  this.render('result', {
    into: 'apis/show',
    outlet: 'result'
  });
}

} });

I have a template rendered, but how do I pass a model (RESULTS) to the template? I want to #each through the model in the template.

Thanks

It’s not reccommended to call render method outside renderTemplate hook. Use a service / component based approach instead.

I touch on this in my talk about routing:

http://alexspeller.com/embercamp-london-talk-routing/

4 Likes

The render API documentation shows how to pass a model:

let results = this.store.findAll('results');
  this.render('result', {
    into: 'apis/show',
    outlet: 'result',
    model: results
  });

However, I would follow @alexspeller’s advise to improve your architecture.

3 Likes

Thanks, I will follow @alexspeller advice.