2013-03-14 74 views

回答

5

這不會以這種方式工作,因爲灰燼必須做執行一些它的神奇。我看了一下灰燼的來源,發現this

// define a computed property 
    Ember.defineProperty(contact, 'fullName', Ember.computed(function() { 
    return this.firstName+' '+this.lastName; 
    }).property('firstName', 'lastName')); 

    @method defineProperty 
    @for Ember 
    @param {Object} obj the object to define this property on. This may be a prototype. 
    @param {String} keyName the name of the property 
    @param {Ember.Descriptor} [desc] an instance of `Ember.Descriptor` (typically a 
    computed property) or an ES5 descriptor. 
    You must provide this or `data` but not both. 
    @param {anything} [data] something other than a descriptor, that will 
    become the explicit value of this property. 

所以下面應該工作你的情況:

Ember.defineProperty(this, 'myComputed', Ember.computed(function() { 
    return "funky"; 
}).property()); 
+0

出色的挖掘。這也是我最終解決的問題。榮譽。 – stevekane 2013-03-15 01:58:20

+0

那麼你如何提供一個相關鍵的計算屬性,使其保持更新? – Chuck 2014-12-09 21:08:42