emberjs ember-cli - 如何删除 {{#each}} 的弃用通知
emberjs ember-cli - how to remove deprecated notice for {{#each}}
这是使用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: '/' });
在todos.js
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
谢谢 - 任何帮助,干杯!
{{#each todo in model}}
<li>{{todo.title}}</li>
{{/each}}
这是使用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: '/' });
在todos.js
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
谢谢 - 任何帮助,干杯!
{{#each todo in model}}
<li>{{todo.title}}</li>
{{/each}}