我正在使用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