dimanche 31 juillet 2016

Ember: How to access another model data in a dynamic segment template

In a dynamic segment template, how do you display data from a model using the route ?

so for example I have those two routes with phone_id as dynamic segment

Router.map(function() {
  this.route('phones');
  this.route('phone', {path: 'phones/:phone_id'});
  this.route('numbers');
});

in phones/:phone_id template, I am trying to show all the numbers model. so in phone.js route, I tried to return the number model and output it but it showed nothing.

import Ember from 'ember';

export default Ember.Route.extend({

  numbers(){
    return this.get("store").findAll('number')
  }

});

I tried it also with the params.phone_id as argument but it did not work. (no error was shown also).

the template phone.hbs looks like

<h5> Device Id: </h5>






funny thing is model.device_id returns the correct one even though I did not even set it to return that in phone.js route. But the each loop for numbers which I did implement something for does not return anything.

Is there a workaround to return number model data in phone.hbs dynamic segment template ?




Aucun commentaire:

Enregistrer un commentaire