I am trying to set model of a route(not nested) but with relationship belong to with setupController
Here is my JSBIN i.e company hasMany Contacts from companies list page I have directly linked to contacts page (want flow that ways)
I want to use the company model to get its contacts list but I am getting error
Error while loading route: TypeError: Cannot call method 'resolve' of undefined
Heres my Router
App.Router.map(function() {
this.resource('companies',{path:'/'});
this.resource('company',{path:'/company/:company_id'});
this.resource('contacts',{path:'/company/:id/contacts'});
});
This is what I am doing
App.ContactsRoute = Em.Route.extend({
setupController: function(controller, model) {
console.log(model.get('contacts')); //This line gives error
//controller.set('model',model.get('contacts'));
}
});
The MODEL
App.Company = DS.Model.extend({
name: DS.attr('string'),
contacts: DS.hasMany('Contact')
});
App.Company.FIXTURES = [{
id: 1,
name: 'company 1',
contacts: ['1']
}, {
id: 2,
name: 'company 2',
contacts: ['1', '2']
}];
App.Contact = DS.Model.extend({
name: DS.attr('string'),
company: DS.belongsTo('Company')
});
App.Contact.FIXTURES = [{
id: 1,
name: 'employee 1',
company: 1
}, {
id: 2,
name: 'employee 2',
company: 2
}];