How to create reusable component in Ember 2.10?


#1

I have a web application with couple pages, each uses Ember app with different components for different logic. But I came up to 1 component is going to be absolutely same for all those pages. I would like to make that component reusable. How to do that in scope of my web application?

I use Ember 2.10.2, ember-cli 2.10.0


#2

Can you elaborate a little further? If you’re simply asking how to make a component in Ember, that’s covered quite well in the guides. If you’re wanting to make a component that can be used by multiple Ember applications, then you need to look into creating an addon to hold the component.


#3

More information please. The general convention is that a component renders data passed to it from a route, but if you’re willing to go against the norm, it’s doable. I’ve done it for my app in many places to keep development time low. Please note that its an anti-pattern but in some situations it helps. I learned how to do it from the blog Ember Igniter https://emberigniter.com/should-components-load-data/