vendredi 2 octobre 2015

Do I always need a template for each route in Ember 2?

Say suppose I have a people's template (people.hbs), and I want to list all the people that is retrieved from http://backendserver/api/people. However in future I have to implement something that requires me to sort these people based on the data that I get from http://backendserver/api/vehicle_people. In this data there is only the people id and the vehicle id , and I get vehicle data from http://backendserver/api/vehicles.

Some of the confusion on how to implement this in Ember2 is

  1. Should I put all this info inside routers/people.js something like this export default Ember.Route.extend({ model(){ return Ember.RSVP.hash({ people_with_vehicle: //find from this.store all the people and the vehicle , people_with_no_vehicle:, all people: }) }

  2. How should I load the data for http://backendserver/api/vehicle_people if I don't want to create any specific route or template ?. In ember2 it does like an automatic load based on the route you go to e.g if you defined in your /adapters/application.js export default DS.RESTAdapter.extend({ namespace: 'api', host:'http://backendserver/' });




Aucun commentaire:

Enregistrer un commentaire