我需要一些幫助將一些javascript轉換爲與coffeescript一起使用的燼。具體來說就是計算屬性。我有以下的javascript代碼:Coffescript和Ember.js計算屬性
Portal.AppsController = Ember.ArrayController.extend({
sortProperties: ['name'],
sortAscending: true,
appsCount: function() {
return this.get('model.length');
}.property('@each'),
updated: function() {
return this.get('model.modified');
}.property('modified')
});
什麼,我想這樣做簡直就是:
removed for brevity
...
appsCount: ->
@get 'model.length'
.property '@each'
...
但這不是有效的語法。這實際上可能嗎?
可能重複[Ember在Coffeescript中計算的屬性](http://stackoverflow.com/questions/12777782/ember-computed-properties-in-coff eescript)(直接從側欄中的*相關*列表中...) –
謝謝。你是對的。 – tomasbasham