TL;DR Embers components are just smart HTML-Templates. Why they dont fetch their data for themself like Angular? And how I can share route models over more urls/pages. It seems that I have to know wich components are placed on which url and I have to make them the data available over the route models. Why is this part not in the component?
I learn at the moment Ember.js. I try at least. At the moment I have a strong problem to understand why Ember.js acts like it do. Please correct me if I am wrong at some statements. I am a Ember.js beginner. So maybe its not right what I point out here.
Lets say we have a Request on /
then Ember tries to find a route model in app/routes/index.js
this file contains the code which data I want to fetch from the backend. Next Ember will render app/templates/index.hbs
in this file I have a component called car-list
.
As far no problems but let us have a closer look. For me it feels very weird that I have to fetch at first the data by myself, why the component doesnt do this on its own? Next problem is then how can I share the model fetch logic between more routes? Maybe I want to place my compoenent on many urls/pages/routes then I have to copy the route model logic?
In my opinion the component should fetch the data by itself, that you easy can insert the component on other pages without copy the whole route model fetch logic.
So I have to know wich components are placed on which url and I have to make them the data available over the route models. Why is this part not in the component?
So maybe I am just not good enough with Ember and I just overlook something?
Aucun commentaire:
Enregistrer un commentaire