lundi 11 janvier 2016

Adding relationship with from different model

-------------------------------
Ember      : 1.13.11
Ember Data : 1.13.15
Firebase   : 2.3.2
EmberFire  : 1.6.3
jQuery     : 1.11.3
-------------------------------

I've got two endpoints in my firebase app. /employees and /subjects. In my ember app I want to add subjects to an employees (employees/$id/subjects). The problem is, I don't know how to load all my subjects from /subjects so I can add them to my array.

This is my routes:

Router.map(function() {
  this.route('dashboard');
  this.route('employees', function() {
    this.route('employee', { path: '/:id'});
  });
});

And this is my model

export default Ember.Route.extend({
  model(params) {
    return this.store.findRecord('employee', params.id);
    }
});

I've tried various things to get this to work, creating a subroute this.route(employee, function(){ this.route('subjects') }, loading a second model in my employee model, none of which has worked. I'm new to ember so I might have gotten some things mixed up. Any helps is appreciated.

Aucun commentaire:

Enregistrer un commentaire