我正在尝试安装 Mirage 并试图伪造服务器的 ember 应用程序。我正在使用 RestAdapter,模型没有从响应中获取数据。
适配器/application.js
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
});
联系人.js(模型)
import DS from 'ember-data';
import ContactModel from 'c360-app/models/contactsmodel';
export default ContactModel.extend({
contactname: DS.attr(''),
groupid: DS.attr(''),
email: DS.attr(''),
contactnumber: DS.attr('')
});
all.js(路由)
import ContactRoute from 'c360-app/routes/contactsroute';
export default ContactRoute.extend({
model: function() {
return this.store.findAll('contacts');
}
});
固定装置/contacts.js
export default [
{
contactname: 'Anusha Swaminathan',
groupid: '12345',
email: 'xyz@gmail.com',
contactnumber: '+91 12345',
isFavourite: true,
isIncomplete: false,
isActive: true,
hasAccess: true
}, {
contactname: 'Sriram Swaminathan',
groupid: '12345',
email: 'xyz@gmail.com',
contactnumber: '+91 12345',
isFavourite: true,
isIncomplete: false,
isActive: true,
hasAccess: true
}, {
contactname: 'Bhuvaneswari Swaminathan',
groupid: '12345',
email: 'xyz@gmail.com',
contactnumber: '+91 12345',
isFavourite: false,
isIncomplete: false,
isActive: true,
hasAccess: true
}
];
场景/default.js
export default function( server ) {
server.loadFixtures();
}
Config.js(幻影)
export default function() {
this.get('/contacts', function(db){
return {contacts: db.contacts};
});
}
联系人列表.hbs
<table class = "contacts-table-header">
<tr>
<th>Contact Name</th>
<th>Group ID </th>
<th>Email Address</th>
<th>Contact Number</th>
</tr>
{{#each model as |contact|}}
<tr>
<td>{{contact.contactname}}</td>
<td>{{contact.groupid}}</td>
<td>{{contact.email}}</td>
<td>{{contact.contactnumber}}</td>
</tr>
{{/each}}
</table>
我不知道我哪里出错了。
请指导。提前致谢!!