在学习余烬的过程中,我没有看到我出错的地方。我尝试从相关的'txplan'模型调用的任何数据都不会呈现。我怀疑我的问题与我的路线有关,可能我做的事情很荒谬。任何建议将不胜感激。我目前没有看到调用txplan API的电话。代码/数据低于
模型/ PAT
const {
attr,
hasMany
} = DS;
export default DS.Model.extend({
txplans: hasMany('txplan', { async: true }),
pat: attr('number'),
fname: attr('string'),
lname: attr('string'),
FullName: attr('string'),
birthdate: attr('date'),
email: attr('string'),
hasins: attr('string'),
estbalance: attr('number'),
imagefolder: attr('string'),
NextAppt: attr('date')
});
模型/ txplan
const {
attr,
belongsTo
} = DS;
export default DS.Model.extend({
pat: belongsTo('pat', { async: true }),
treatmentplannum: attr('number'),
heading: attr('string'),
dateTP: attr('date'),
proccode: attr('string'),
descript: attr('string'),
fee: attr('number')
});
路线/ PAT
import Route from '@ember/routing/route';
export default Route.extend({
model() {
return this.store.findAll('pat');
},
setupController(controller, model)
{ Ember.set(controller, 'pat', model) }
});
模板(电子邮件将显示,标题和费用不会。我一直在尝试post.value和post.txplan.value。
{{#each pat as |post|}}
{{post.email}}
{{post.heading}}
{{post.txplan.fee}}
{{/each}}
数据/ PAT
{"status":200,"error":null,"pats":
[{"id":1,"pat":1,"fname":"Test","lname":"User","FullName":"Test
User","birthdate":"1980-11-22,"email":"testuser@test.com","hasins":"I","estbalance":0,
"imagefolder":"TestUser1","NextAppt":null}
数据/ txplan
{"status":200,"error":null,"txplan":
[{"id":1,"treatplannum":3,"pat":1,"heading":"Active",
"dateTP":"2018-02-23","proccode":"T4528","descript":"Amalgam-1
Surf","Fee":70,"priority":0}
答案 0 :(得分:0)
我认为这个问题与我的数据结构有关。我能够通过在我的路线中使用RSVP并将相同的参数传递给每个模型来解决这个问题:
model(params) {
return Ember.RSVP.hash({
pat: this.store.query('pat', {pat: params.pat}),
txplan: this.store.query('txplan', {pat: params.pat})
})
}