Tomas
Tomas

Reputation: 1467

How to render Ember component dynamically

Rendering a component works well when using {{component-name}} in template. I want to render a component from route with dynamic parameters. I've tried this

App.ApplicationRoute = Ember.Route.extend({
  init: function(){
      this.render("components/comp-two", {
        into: "application",
        outlet: "test"
      });

  }
});

It successfully renders a template, but component's events(init, didInsertElement) and actions don't work.

How to make events and actions work ?

example: http://emberjs.jsbin.com/badaku/1/

Upvotes: 5

Views: 2455

Answers (1)

Vaibhav
Vaibhav

Reputation: 1477

If you give some template name in render method, ember only will render that specific template, it will not be considered as a component.You can create a dummy template, inside that you can use your component.

I have updated your jsBin example http://jsbin.com/pajirefeta/1/edit

Upvotes: 3

Related Questions