EmberJS,帮助程序调用中的字符串插值
EmberJS, String interpolation in a helper call
我的模板中有这个助手调用:
{{my-helper id='myID'}}
我想让 id
参数值更动态一点,例如:
{{#each charts as |chart|}}
{{my-helper id='chart' + chart.id}}
{{/each}}
我如何使用字符串插值和连接为助手调用中的参数创建值?
您可以使用 concat 助手来执行此操作:
{{#each charts as |chart|}}
{{my-helper id=(concat 'chart' chart.id)}}
{{/each}}
它不是ES2015 String interpolation,但它会做你想做的事。
我的模板中有这个助手调用:
{{my-helper id='myID'}}
我想让 id
参数值更动态一点,例如:
{{#each charts as |chart|}}
{{my-helper id='chart' + chart.id}}
{{/each}}
我如何使用字符串插值和连接为助手调用中的参数创建值?
您可以使用 concat 助手来执行此操作:
{{#each charts as |chart|}}
{{my-helper id=(concat 'chart' chart.id)}}
{{/each}}
它不是ES2015 String interpolation,但它会做你想做的事。