ember.js - Who defines the "store" object? -
from code snippet :
todos.todoscontroller = ember.arraycontroller.extend({ actions: { createtodo: function() { // todo title set "new todo" text field var title = this.get('newtitle'); if (!title.trim()) { return; } // create new todo model var todo = this.store.createrecord('todo', { title: title, iscompleted: false }); // clear "new todo" text field this.set('newtitle', ''); // save new model todo.save(); } } });
which is, in fact, ember website
who defines (and defined) this.store ? looked in controller class , in dsl
the store
ember data bookkeeping object.
it has been injected via ember's dependency injection api application's controllers , routes using initializer, can referenced route or controller this.store
the store
same instance of 'store:main' regardless of called from, because has been injected.
Comments
Post a Comment