2016-07-28 7 views
0

操作フック(保存)から別の保存(保存後)にコンテキストを渡す必要がありますが、ctx.hookStateexistenceは認識されますが動作しません。'保存後のコンテキスト'を保存します

ZZ.observe('persist', (ctx, next) => { 
     ctx.hookState = "pass this"; 
     next(); 
    }).catch(err => next(err)); 
    }); 

ZZ.observe('after save', (ctx, next) => { 
    console.log(ctx.hookState); 
    next() 
}); 

console.log(ctx.hookState)には何も表示されません。私は間違っているの?

ありがとうございました。

答えて

1

あなたは、このように行うことができますhookState

上書きしないでください。

ZZ.observe('persist', (ctx, next) => { 
     ctx.hookState.foo = "pass this"; 
     next();  
    }); 

ZZ.observe('after save', (ctx, next) => { 
    console.log(ctx.hookState.foo); 
    next() 
}); 
+0

うん、全てのセンスを作ります!ありがとうございました。 –

関連する問題