我正在构建的 Ember.JS 应用程序有点问题:
App.userController = Ember.ArrayController.create({
content: [],
init: function() {
this.set('content', []);
this.refresh();
},
refresh: function() {
//Refresh Action
}
});
App.supplierController = Ember.ArrayController.create({
content: [],
init: function() {
this.set('content', []);
this.refresh();
},
refresh: function() {
//Refresh Action
}
});
<h1>Users</h1>
{{#each user in App.userController}}
{{user.name}} - {{user.age}}
{{/each}}
<h1>Suppliers</h1>
{{#each supplier in App.supplierController}}
{{supplier.name}} - {{supplier.revenue}}
{{/each}}
它有效......但用户显示在与供应商相同的列表中?如果我删除供应商控制器,它们会显示在正确的位置。我认为这与有两个实例有关,Ember.ArrayController
但我不确定。它显示如下:
Users
-----------
Suppliers
-----------
User 1 -
User 2 -
Supplier 1 - £100
什么时候应该显示这个:
Users
-----------
User 1 - 30
User 2 - 25
Suppliers
-----------
Supplier 1 - £100