2017-05-02 5 views
0

最初にアプリケーションをロードした後、ブラウザの戻るボタンをクリックすると、ブラウザのルートURLは#に変わり、ブランク。私は、ブラウザの戻るボタンを押してデフォルトのビューにリダイレクトしたいと思います。提案?空白のコンテンツブラウザの戻るボタンをクリックしているとき(私の角2のアプリケーションでルーティングの問題)

最初のページを読み込み中です。 initial page on loading

バックボタンを押したとき。 On pressing the back buttton

ルーティングページコード。

export var DynaRoutes: Routes = [ 
{ 
    path: '', 
    component: DynaMainView, 
    children: [ 
     { 
      path: 'reports', 
      data: { 
       text: 'Reports', 
       name: 'Reports', 
       image: './app/assets/img/icons/reports.svg', 
       iconId: 'formModeling', 
      }, 
      children: [ 
       { 
        path: '', 
        component: DynaReportsView 
       } 
      ] 
     }, 
     { 
      path: 'analyze', 
      data: { 
       text: 'Analyze', 
       name: 'Analyze', 
       image: './app/assets/img/icons/analyze.svg', 
       iconId: 'screenModeling' 
      }, 
      children: [ 
       { 
        path: '', 
        component: DynaAnalyzerView, 
       } 
      ] 
     }, 
     { 
      path: 'updates', 
      data: { 
       text: 'Updates', 
       name: 'Updates', 
       image: './app/assets/img/icons/analyze.svg', 
       iconId: 'screenModeling', 
       disabled: true 
      }, 
      children: [ 
       { 
        path: '', 
        component: DynaUpdatesView 
       } 
      ] 
     } 
    ] 
} 

];

答えて

0

これが役立つかどうかはわかりません。

{ path: '', redirectTo: 'path to default route', pathMatch: 'full' } 

あなたの親にredirectTopathMatch属性を追加します。

+0

私はそれを試みました。しかし、それは動作していませんでした。 –

0

私は解決策を見つけました。これは私のために働いた。

if (this.router.url == '/') { 
     this.router.navigate(['reports']); 
    } 
関連する問題