0

nodeEditControllerfromを取得しようとすると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;
    },
    ...

エラーは次の行で発生します。

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

なぜなら:

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

を返しますundefined。何故ですか?NodeEditControllerが定義されています!

4

1 に答える 1