【发布时间】:2016-07-24 19:51:44
【问题描述】:
我在访问组件中的输入值时遇到问题。我正在尝试在我的模板中动态创建值绑定并使用 this.controller.get("pst"+id) 在 conponent.js 文件中进行访问,但是结果不足。使用 Ember 2.2
{{#each post in |pst idx|}}
{{input value=(concat 'pst' idx)}}
{{/each}}
【问题讨论】:
-
Ember 版本?试试
{{#each post as |pst idx|}} -
创建绑定值的变量似乎是个问题。 concat 辅助函数构建一个字符串,但是当我在动态创建的字符串上尝试 this.get.controller("..") 时,它不会返回输入框的值(并返回未定义)
-
我相信您需要的是
get助手,可能与 concat 结合使用:(get this (concat "pst" idx))。 -
我没有骰子就试过了。我也试过 this.get('idx'+i);
标签: javascript ember.js handlebars.js htmlbars