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({
model:function(params){
//console.log(this.modelFor('location'));
var location = this.store.find('location', params.location_id);
return location;
},
setupController: function(controller, model) {
controller.set('model', model);
controller.set('countries', this.store.find('country'));
}
});
//controller/location/edit.js
import Ember from 'ember';
export default Ember.ObjectController.extend({
countryList: function(){
console.log(this.get('countries'));
var countries = this.get('countries');
var myCountries =[];
countries.forEach(function(country){
myCountries.push({
id: country.get('id'),
text: country.get('name'),
value:country
});
return myCountries;
});
}.property('countries.@each.name')
});