我有一个带有 People 模型的 Ember.js ArrayController。我正在尝试创建一个计算属性来生成人们体重的平均值。看起来这应该相当容易,但我被卡住了。这是我的代码。
App.PeopleController = Ember.ArrayController.extend({
//each model in the array has a "weight" property
averageWeight: function() {
//I don't know what to do here
}.property('@each.weight')
});
车把代码。
{{#each controller}}
{{name}}
{{/each}}
Average weight: {{weight}}