Computed property is not working for ember cli when route pass value to controller


I created a setup controller to assign value of the countries for select2 input, im having trouble accessing the data in the controller

// location/edit.js   
 import Ember from 'ember';

export default Ember.Route.extend({
        var location ='location', params.location_id);
        return location;
    setupController: function(controller, model) {
        controller.set('model', model);

import Ember from 'ember';

export default Ember.ObjectController.extend({

 countryList: function(){

        var countries = this.get('countries');
        var myCountries =[];


                id: country.get('id'),
                text: country.get('name'),
            return myCountries;



You are making a find in the setupController method. This method doesnt wait for promises you return. For this case you have the afterModel hook or the beforeModel hook. So when you set the model of the CountriesController, you are setting a promise on it, which aint working of course.

you can load the countries by return the find promise in one of the mentioned hooks. And in the setupController method, you can write:


the “all” method instantly gives you all the countries in the store without making a fetch from the backend or returning a promise.


The route will wait for the aftermodel hook to resolve prior to pass to setupController? In any case, you don’t have access to the controller in any of the *model hooks, so you probably want to perform a store.find in any of them and, if the router would wait for the promise to return, set the countries in the setupController hook as @gerrit said.