In a dynamic segment template, how do you display data from a model using the route ?
so for example I have those three 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: {{model.device_id}}</h5>
{{#each numbers as |number|}}
{{number.digits}}
{{/each}}
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 ?
EDIT:
the way I am reaching my dynamic segment is through a link to:
{{#each phones as |phone|}}
<li>{{#link-to 'phone' phone}} {{phone.id}}{{/link-to}}</li>
{{/each}}