我想在我的Ember模型中聲明瞬態屬性,但不影響模型的「髒」狀態。瞬態和非髒屬性,餘燼數據
此刻,我宣佈他們喜歡這個模型中:
eventId: DS.attr("string", {defaultValue: "", transient: true})
他們在串行器被忽略,所以他們不會被髮布到API:
App.ApplicationSerializer = DS.RESTSerializer.extend({
serializeAttribute: function(record, json, key, attribute) {
if (attribute.options.transient) { return; }
return this._super(record, json, key, attribute);
}
});
但這事我還要求這些屬性不會更改對象的「髒」狀態(用於跟蹤和回滾而不觸及它們)。
不太確定我明白。那麼我該用什麼來代替 'mapaLat:DS.attr()' – klavado
就像你對每個其他Ember「對象」所做的一樣,這意味着你會使用'mapaLat:「你的價值,就像那樣簡單」 '沒有包裝在'DS.attr()'中 –