这是使用 ember-cli 0.2.3
(型号)todo.js
import DS from 'ember-data';
export default DS.Model.extend({
title: DS.attr('string'),
isCompleted: DS.attr('boolean')
}).reopenClass({
FIXTURES: [
{
id: 1,
title: "Complete Ember.js Tutorial",
isCompleted: false
},
{
id: 2,
title: "Checkout some more ember stuff",
isCompleted: true
},
{
id: 3,
title: "Solve world hunger (with Ember)",
isCompleted: false
}
]
});
router.js中的
this.resource('todos', { path: '/' });
export default Ember.Route.extend({
model: function() {
return this.store.find('todo');
}
});
todos.hbs中的
{{#each}}
//some code here using the model
{{/each}}
开发者控制台中的收到了此通知:
DEPRECATION: Using the context switching form of {{each}} is deprecated.
Please use the keyword form (`{{#each foo in bar}}`) instead
请提供有关删除弃用通知的实际每个代码的建议。
以下是我尝试过的代码:
1 - {{#each todo in todo}} //no error, but no data in todo list
2 - {{#each todo in controller.todo}} //no error, but no data in todo list
3 - {{#each todo in todos.todo}} //no error, but no data in todo list
4 - {{#each todo in todos}} //no error, but no data in todo list
谢谢 - 任何帮助,欢呼!
答案 0 :(得分:1)
{{#each todo in model}}
<li>{{todo.title}}</li>
{{/each}}