2013-04-11 5 views
0

При попытке получить nodeEditController от nodeController:startEditing, я получаю следующую задачу:контроллер определен, но не может быть найден

Uncaught TypeError: Cannot call method 'set' of undefined 

Это NodeController:

SettingsApp.NodeController = Ember.ObjectController.extend({ 
    isEditing: false, 

    startEditing: function() { 
     debugger; 
     var nodeEditController = this.get('controllers.nodeEdit'); 
     nodeEditController.set('content', this.get('content')); 
     nodeEditController.startEditing(); 
     this.set('isEditing', true); 
    }, 
    ... 

Это NodeEditController :

SettingsApp.NodeEditController = Ember.ObjectController.extend({ 
    needs: ['node'], 

    startEditing: function() { 
     //debugger; 
     // add the contact and its associated phone numbers to a local transaction 
     var node = this.get('content'); 
     var transaction = node.get('store').transaction(); 
     transaction.add(node); 
     // contact.get('phones').forEach(function (phone) { 
     // transaction.add(phone); 
     // }); 
     this.transaction = transaction; 
    }, 
    ... 

Ошибка произошла i п линия:

nodeEditController.set('content', this.get('content')); 

Потому что:

var nodeEditController = this.get('controllers.nodeEdit'); 

Возвращает undefined. Почему это? Определяется NodeEditController!

ответ

4

NodeController пропускает needs свойство:

SettingsApp.NodeController = Ember.ObjectController.extend({ 
    needs : ["nodeEdit"], 
    isEditing: false, 

    startEditing: function() { 
     debugger; 
     var nodeEditController = this.get('controllers.nodeEdit'); 
     nodeEditController.set('content', this.get('content')); 
     nodeEditController.startEditing(); 
     this.set('isEditing', true); 
    }, 
    ... 
+0

Действительно! Теперь это работает. Я принимаю, как только могу ... – dangonfast

Смежные вопросы