mercredi 7 janvier 2015

Loading models in Component

I've made a component that produces a drop down list used to select an item from a possible list of items based on the passed in type:



{{item-selector type="type1"}}


I dont want to load the items on page load cause theres potentially a lot of them and many times they won't need to be loaded. I would prefer loading them on user interaction with the component. That nixes out loading them in the route.


Since components don't have access to the store, I've been experimenting with passing in a controller for the items:



{{item-selector type="type1" widget=controllers.type1}}


I'm using widget cause I can't think of a better property name and controller is already taken. Suggestions welcome.


But now I'm unsure about how to load the models in the controller. Should I do it in init? Or maybe a computed property? I'm unsure.


Suggestions on how to solve this would be appreciated.





Aucun commentaire:

Enregistrer un commentaire