我有一个模板,它为模型中的每条记录创建一个组件。我想找到一个组件并在运行时根据来自其他模板的事件更新它的一个属性。如何找到插入到 DOM 中的特定组件。{{#each}} {{我的名字}} {{/each}}
<script type="text/x-handlebars" data-template-name="components/my-name">
Hi, my name is {{name}}.
</script>
var App = Ember.Application.create();
App.IndexRoute=Ember.Route.extend({
model:function(){
return dummyNames;
}
});
var dummyName={[name='John', name='Jane', name='Jade']};
此代码将在屏幕上显示名称。现在我有另一个名为 change 的模板。
<script type="text/x-handlebars" data-template-name="change">
<button {{action 'changeNow'}}></button>
</script>
App.ChangeController=Ember.Controller.extend({
actions:{
changeNow:function(){
//Here I want to find the component where the name is Jane and change it to Kate. How to do this?
}
}
});