How to load partials / views / templates dynamically in Ember.js

后端 未结 4 1631
耶瑟儿~
耶瑟儿~ 2021-02-04 14:14

So I have the following setup.

On the main page, a list of generators is being displayed based on a list coming from a model using fixture data.

Now when one of

4条回答
  •  萌比男神i
    2021-02-04 15:12

    @KamrenZ already mentioned this but I figured I'd cite chapter and verse for those looking into this. More recent versions of Ember gracefully accept bound property names and use them in the partial helper:

    http://ember-doc.com/classes/Ember.Handlebars.helpers.html#method_partial

    BOUND TEMPLATE NAMES The parameter supplied to partial can also be a path to a property containing a template name, e.g.:

    {{partial someTemplateName}}
    

    The above example will look up the value of someTemplateName on the template context (e.g. a controller) and use that value as the name of the template to render. If the resolved value is falsy, nothing will be rendered. If someTemplateName changes, the partial will be re-rendered using the new template name.

提交回复
热议问题