Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 控制器已定义,但找不到_Ember.js - Fatal编程技术网

Ember.js 控制器已定义,但找不到

Ember.js 控制器已定义,但找不到,ember.js,Ember.js,尝试从nodeController:startEditing获取nodeEditController时,出现以下问题: Uncaught TypeError: Cannot call method 'set' of undefined 这是节点控制器: SettingsApp.NodeController = Ember.ObjectController.extend({ isEditing: false, startEditing: function () {

尝试从
nodeController:startEditing
获取
nodeEditController
时,出现以下问题:

Uncaught TypeError: Cannot call method 'set' of undefined
这是
节点控制器

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);
    },
    ...
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;
    },
    ...
这是
NodeEditController

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);
    },
    ...
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;
    },
    ...
错误发生在以下行中:

nodeEditController.set('content', this.get('content'));
因为:

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

返回未定义的
。为什么呢?
NodeEditController
已定义

节点控制器缺少
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);
    },
    ...

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);
    },
    ...