2017-07-27 8 views
1

ブラウザを使用してルートに直接ナビゲートすると、アプリケーションは再ブートストラップし、正しいページ/コンポーネントに移動します。 たとえば、ボタンを操作すると、アプリケーションを再起動せずに直接そこに移動します。角4ルータ:直接ブラウザナビゲーション再開アプリケーション

これが期待どおりの動作ですか? どうすればこの問題を防ぐことができますか?

私たちは私たちの認証にIDサーバを使用しています。コールバックURLが必要です。これは直接ブラウザのナビゲーションのように扱われ、アプリケーションは再起動します。

我々のアプリ-routing.moduleは、次のようになります。

const routes: Routes = [ 
    { path: '', redirectTo: '/dashboard', pathMatch: 'full' }, 
    { path: 'dashboard', component: DashboardComponent, canActivate: [RouteGuardService] }, 
    { path: 'users', component: UsersMainComponent}, 
    { path: 'vendors', component: VendorMainComponent}, 
    { path: 'invoices', component: InvoicesMainComponent}, 
    { path: 'offers' , component: EsdMainComponent}, 
    { path: 'settings' , component: SettingsMainComponent}, 
    { path: 'callback' , component: CallbackComponent}, 
    { path: 'createvendor' , component: CreateVendorsComponent, canActivate: [RouteGuardService]}, 
    { path: 'customerdashboard' , component: CustomerDashboardComponent}, 
]; 

@NgModule({ 
    imports: [RouterModule.forRoot(routes)], 
    exports: [RouterModule], 
    providers: [RouteGuardService] 
}) 
export class AppRoutingModule { } 

コールバックパスは、アイデンティティ・サーバー用のコールバックURLです。

+0

これに対する解決策はありますか? – Boris

答えて

1

はいこれは予想される動作です。 Angularアプリケーション内でボタンを使ってルーティングする場合は、単にpushStateを使用して履歴as described in the docs(下を下に)を変更します。

直接操作すると、index.htmlが取得され、アプリをブートストラップすると、現在のURLが表示され、表示するコンポーネントが決まります。

The answer to this questionあなたの問題を解決する方法についてお手伝いします。

+0

有用な情報をありがとう。残念ながら、あなたが関連する質問に提供したリンクは役に立たなかった。 – hholtij

関連する問題