【发布时间】:2016-02-12 06:49:03
【问题描述】:
我的 Spring 后端有一个 JSON 对象。如何在 Ember 应用商店中创建数据对象?
我试过了:
createObject() {
var _this = this;
$.getJSON('http://localhost:8080/object/getCard?id=24').then(function(response) {
_this.store.createRecord('cards/object/card', response);
});
}
JSON:
{
"id":24,
"fullName":"qwerty",
"form":"zzzzzzzzzzzz",
"leader": {
"id":23,
"fullName":"testName test",
"email":"emailTest"
}
}
我在 Ember 应用中有一个模型
export default DS.Model.extend({
fullName: DS.attr('String'),
form: DS.attr('String'),
leader: DS.belongsTo('contact', { async: true })
}
及联系方式:
export default DS.Model.extend({
fullName: DS.attr('String'),
email: DS.attr('String')
});
【问题讨论】:
标签: json ember.js ember-data