谁定义"store"对象?



来自以下代码片段:

Todos.TodosController = Ember.ArrayController.extend({
  actions: {
    createTodo: function() {
      // Get the todo title set by the "New Todo" text field
      var title = this.get('newTitle');
      if (!title.trim()) { return; }
      // Create the new Todo model
      var todo = this.store.createRecord('todo', {
        title: title,
        isCompleted: false
      });
      // Clear the "New Todo" text field
      this.set('newTitle', '');
      // Save the new model
      todo.save();
      }
    }
});

事实上,它来自Ember网站

谁定义(在哪里定义)this.store?我查看了Controller类和DSL

store是Ember Data记账对象。

它已经通过Ember的Dependency Injection API使用Initializer注入到应用程序的控制器和路由中,因此它可以从任何路由或控制器引用为this.store

store始终是"store:main"的同一实例,无论从何处调用它,因为它已被注入。

最新更新