0
votes

I have a template that has drop down that I would like it to be pre-populated with data coming the API. I thought of setting a controller properties from the setupController hook the problem is the template seems to be rendered before the promise from the store.findAll() is resolve causing a bit of flicker. Is there a hook/pattern so everything is loaded before the template is rendered.?

1

1 Answers

1
votes

You'll want to use Ember.RSVP.hash to load multiple models, and use them in setupController.

Something like this:

export default Ember.Route.extend({
  model() {
    return Ember.RSVP.hash({
      dropdowndata: this.store.findAll('model1'),
      otherdata: this.store.findAll('model2')
    });
  },
  setupController(controller, model){
    controller.set('dropdowndata', model.dropdowndata)
    controller.set('model', model.otherdata)
  }
});