我正在使用Ember.js中的表單,我想檢索所有模型屬性的列表,以便我可以在不同時刻拍攝表單狀態的快照。有沒有辦法獲得模型的所有屬性列表?如何檢索Ember.js模型的所有屬性
例如,如果我的模型是:
App.User = DS.Model.extend({
name: DS.attr('string'),
email: DS.attr('string'),
current_password: DS.attr('string'),
password: DS.attr('string'),
password_confirmation: DS.attr('string'),
admin: DS.attr('boolean'),
}
然後,我想有這樣的事情:
> getEmberProps('User')
["name", "email", "current_password", "password", "password_confirmation", "admin"]
JSON.stringify?你嘗試過嗎? – marko 2013-03-27 12:22:58
嗯,我不會知道如何JSON.stringify到Ember模型 – joscas 2013-03-27 12:46:34