2017-01-17 13 views

答えて

0

はそれを考え出し

$transitions.onBefore({}, (trans) => { 
    console.log("before a transition"); 
    console.log(trans); 

    //I want to broadcast an event here 
    //notifying inner components that it's about to switch state 
    //The event will contain the trans 
    //So I actually don't need to wait here, I just need to suspend the trans at this point. 

    //The inner component will respond by emitting and event. 
    //That event will contain approval status, and the trans object. 
    //My code can simply check the approval status; If false, 
    //it simply does nothing. Otherwise it will pick and resume the trans. 
}); 

ありがとう:このスニペットは、おそらく私の意図を説明することができます。これはアイディアを示しています。

まず、window.counterで、あなたのboot.js 0に設定/ app.js ...、としているあなたのコントローラの$のOnInit:

$transitions.onBefore({}, (trans) => { 
    if (window.counter == 0) { 
    this.$timeout(() => trans.run(), 2000); 
    window.counter += 1; 
    return false; 
    } 
}); 

あなたが最初にあなたの移行がキャンセルされた時にわかります...、2秒後に再実行されます。

0

TransitionHookFnは、HookResultを返します。これは、約束が解決されるまで移行を延期するという約束の形で行うことができます。

$transitions.onBefore({}, $transitions => { 
    return this.$timeout(() => { 
    /* 
    * Do something here. 
    * Once this is completed, transition can resume 
    * unless promise is rejected or resolves to a false value 
    */ 
    }, 2000); 
}); 

参考:https://ui-router.github.io/ng1/docs/latest/modules/transition.html#hookresult

この場合

、私たちは、次の操作を行うことができます

関連する問題