1
我有一個ArrayController,我想根據特定鍵的值對該ArrayController的內容進行分組。Ember.js:對ArrayController進行分組/分區
例如,如果在我的ArrayController對象是:
id status name
-----------------------------
1 1 some name
2 1 some other name
3 2 blah
4 3 blah again
然後,我會通過status
希望對內容進行分組。
要做到這一點,我想在我的ArrayController使用計算性能:
App.SomeArrayController = Ember.ArrayController.extend({
itemController: 'some-item',
status1: Ember.computed.filterBy('content', 'status', 1),
status2: Ember.computed.filterBy('content', 'status', 2),
status3: Ember.computed.filterBy('content', 'status', 3)
});
在模板中,這些都顯示,但他們不由itemController我在指定的被包裹ArrayController:
// item controller used in the ArrayController
App.SomeItemController = Ember.ObjectController.extend({
anotherKey: function() {
return 'hey ' + this.get('name');
}.property('name')
});
<!-- template to display status=1 items -->
{{#each status1}}
// displays the name (as a property from the model)
{{this.name}}
// nothing displays here
// (leading me to believe it is not being wrapped by the item controller)
{{this.anotherKey}}
{{/each}}
我在做什麼錯?