Reputation: 110892
I want to build a component to display the tags of an item like on the mac where every tag has its color. Most stuff I read about components say that the component should not excess any model directly. But in this case I had to pass the list of tags for an item and additionally the tag/color combinations. I wonder what will be the ember way to have the tag/color combination in the component without passing it every time I use the component.
In the end I wanna call the component like this
{{tag-list tags=item.tags}}
The question for me is, how can the component get the color/tag combination model without passing it every time I use the component, cause in this case the view needs to that use the component needs to know this model. This seems a bit odd cause all the view should know is, that there will be a component that will renderer the tags.
Upvotes: 0
Views: 379
Reputation: 7464
If I understand you correctly, you're wondering how to pass a model into a component?
// if item is just referring to your model
{{tag-list tags=tags}}
// if item is a property in your model
{{tag-list tags=item.tags}}
So it appears that it should work just like you hope it well. See the Ember guide to passing properties into a component. If you're having a problem getting it to work properly, I think there's an error elsewhere in your code.
Upvotes: 1