2017-08-07 11 views
0

みんな。 私は@ angular/routerを持っています。 私のアプリケーションのルート設定があります。子供用ナビゲーションAngular2

Router [] = [ 
    { 
     path: 'main', 
     component: MainComponent, 
     children: [ 
      { 
      path: 'info', 
      component: InfoComponent 
      } 
     ] 
    } 

と私は、次のフローがあります。私のエントリーページをし、それだけでDBからオブジェクトを得ること、MainComponentに移動します。 MainComponentの内部ではthis.router.navigate(['info'], {relativeTo: this.route})を使用します。 がMainComponent

export class InfoComponent extends OnInit { 

    constructor (@Host() private parent: MainComponent) {} 

    ... 

    ngOnInit() { `componentResolver is done` } 
} 

から親に依存して私はcomponentResolverを持ってInfoComponentでは、問題は、私はクロームナビゲーションバーの[戻る]ボタンで戻って移動するときに、ある、またはAltキー+ <をクリックすると、それだけで空のビューを私に示しています(MainComponent)。 私の問題はどこにありますか?これはどうして起こったのですか?

答えて

2

代わりMainComponent(そうthis.router.navigate(['info'], {relativeTo: this.route})を除く)で手動ナビゲーションを自分で行うので、このルータの設定を試してみてください。

Router [] = [ 
    { 
     path: 'main', 
     component: MainComponent, 
     children: [ 
      { 
      path: '', 
      redirectTo: 'info', 
      pathMatch: 'full' 
      }, 
      { 
      path: 'info', 
      component: InfoComponent 
      } 
     ] 
    } 
+0

これは私がの一つにこの設定を持っている 'Router.navigate' – Dummy

+0

の呼び出しとまったく同じです私のアプリケーションと私は戻ってナビゲートするときにOPが述べた問題はありません。 –

関連する問題