我在ember-data中有一个模型,定义为:
App.Note = DS.Model.extend({
content: attribute('string'),
createdDate: attribute('string', {
defaultValue: function() {return new Date()}
}),
title: function() {
// do stuff
}.property('content', 'createdDate')
});我注意到,当我使用以下命令创建新对象时:
this.store.createRecord('note');不计算title属性。我假设默认值会触发属性更新,但事实并非如此。如何获取默认值以同时触发计算属性?
发布于 2014-05-21 16:16:29
我认为问题在于你使用了“content”作为属性名。我会避免使用这个词,因为Ember本身就倾向于大量使用它,而且它会把事情搞砸。这是你的代码的jsbin:http://emberjs.jsbin.com/jebugofo/6/edit?html,css,js,output。只需去掉该属性的名称。
https://stackoverflow.com/questions/23771533
复制相似问题