kroofy
kroofy

Reputation: 984

Creating Ember View dynamically by setting templateName in Template

I wish to load my View using a variable like this:

{{#if model.isLoaded }}
  Loaded: {{ model.template.slug }}
  {{ view App.DocumentView templateName="model.template.slug" }}
{{ else }}
  Loading…
{{/if}}

Is there a way to pass variable to a View like this? How could I otherwise load it when my model gets updated?

Upvotes: 2

Views: 1282

Answers (2)

Juan Jardim
Juan Jardim

Reputation: 2252

I created a library to help with this kind of issue, check at github

Upvotes: 0

ken
ken

Reputation: 3745

Use Binding to bind the template's name to your model's property.

{{#if model.isLoaded }}
  Loaded: {{ model.template.slug }}
  {{ view App.DocumentView templateNameBinding="model.template.slug" }}
{{ else }}
  Loading…
{{/if}}

Upvotes: 3

Related Questions