Sunjay Varma
Sunjay Varma

Reputation: 5115

Ember - Can I use an Ember Component outside of a template?

Let's say I have a component called MyComponent. Is there anyway I can render that component into an outlet like I would with a regular template.

I am calling render from a Route. The reason I'm using a component is because I want to reuse a lot of my HTML, but also want to take advantage of the "public API" like aspects of components.

Can I achieve this with Ember? Thanks for your help.

Upvotes: 0

Views: 134

Answers (1)

Steve H.
Steve H.

Reputation: 6947

Sure, you can specify a template id or the actual template content itself in a view. Instead of using the templateName property, set the template property lke this:

App.MyComponentView= Ember.View.extend({
    template: Ember.Handlebars.compile("{{my-component}}");
});

Hope that helps.

Upvotes: 0

Related Questions