Path 如何在Ember中的路径中使用索引

Path 如何在Ember中的路径中使用索引,path,ember.js,Path,Ember.js,我试图将textfield绑定到对象中的值,如下所示: {{{#controller.currentTypes}中的每个类型 {{type.name} {{view Ember.TextField valueBinding=“controller.contextmarkets[type.id]”} {{/每个}} controller.currentTypes和controller.contextComments仅以松散的一对多方式关联 currentTypes=[{id:1,name:'Ty

我试图将textfield绑定到对象中的值,如下所示:

{{{#controller.currentTypes}中的每个类型
{{type.name}
{{view Ember.TextField valueBinding=“controller.contextmarkets[type.id]”}
{{/每个}}
controller.currentTypes
controller.contextComments
仅以松散的一对多方式关联

currentTypes=[{id:1,name:'Type name 1'}]
我不知道我是否在实现一个反模式,但我认为我不能没有动态索引,而且Ember似乎不允许我在路径中使用索引

我试图用一个额外的视图或辅助对象来解决这个问题,但一直被卡住。
有没有一个解决办法

因此,我通过在控制器上添加计算属性并将生成的数组存储在私有属性中解决了这个问题:

App.MyController=Ember.Controller.extend({
备注:功能(){
var备注=this.get('currentTypes')||[];
此._备注=备注.map(功能(备注){
返回{
id:remark.id,
name:remark.name,
值:“”
};
});
把这个还给我;
}.property('currentTypes')
});
}
现在的视图如下所示:

{{{#每句话}
{{name}}
{{view Ember.TextField valueBinding=“value”}
{{/每个}}

现在我可以访问_备注来查找用户的输入,这是我能想到的最像余烬的解决方案,可能是“正确的解决方案。”

看到一个JSFIDLE会有帮助。从你的例子中,我无法确切地说出你想要完成什么。另外,如果
type
与contextRemarks相关,那么type应该属于/hasOne contextRemark。对于relation语句,我的意思是说我不能在controller.currentTypes中存储额外的信息