emberjs ember-cli - 如何删除{{#each}}的弃用通知

时间:2015-04-30 08:13:44

标签: javascript ember.js ember-cli

这是使用 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

谢谢 - 任何帮助,欢呼!

1 个答案:

答案 0 :(得分:1)

{{#each todo in model}}
  <li>{{todo.title}}</li>
{{/each}}