How to render component/helper by name from instance field?

后端 未结 2 776
执笔经年
执笔经年 2021-01-24 07:27

Is there way to use component from controller/view field

So instead of using

{{contact-select label=\"Label:\" contacts=form.prop}}
// or
{{input-field         


        
2条回答
  •  攒了一身酷
    2021-01-24 07:53

    At version 1.11 there are component helper

    for early versions i found relative question / answers: How to dynamically load ember components by name in a template? how can I invoke an ember component dynamically via a variable?

    For my goals i adapt code so

    https://github.com/vvs-code/ember-render-helper

    and now i can use in my template

    {{renderComponent field.type _param=field.value label=field.label}}
    

    to get the same as

    {{input field.value label=field.label}}
    

    P.S> as variat - it possible get code from https://github.com/emberjs/ember.js/pull/10093 and port it into project directly

提交回复
热议问题