2016-12-09 17 views
2

Angular1では、アプリケーションはすべてのリソースを取得して初期化するために、初期ロード時に1〜3秒かかります。その後、別のルートに移動すると#urlに#tab1が追加され、すぐにそのルートに切り替わります。Angular2ルータの高速化方法

これはAngular2でも可能ですか?

angle.ioの各例では、アプリ全体を再読み込みするので、ローダーで空白の画面を見ながら1〜3秒かかります。 #pathは追加されません。私は別のルータを使用してその速度に戻るべきでしょうか?

index.htmlを

<html> 
<head> 
    <base href="/"> 

は、ここに私のルータの設定です:

const appRoutes: Routes = [ 
    { path: 'classes', component: ClassesComponent }, 
    { path: 'classes/:id', component: ClassDetailComponent }, 
    { path: 'products', component: ProductsComponent }, 
    { path: 'products/:id', component: ProductDetailComponent }, 
    { path: '', redirectTo: 'products', pathMatch: 'full' }, 
    { path: 'cache/clear', component: CacheComponent }, 
    { path: '**', component: PageNotFoundComponent } 
]; 

export const appRoutingProviders: any[] = []; 
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); 
+0

これが起こっている場合は、セットアップにかなり間違っています。あなたは 'HashLocationStrategy'に切り替えることができますか? ''要素(または 'APP_BASE_HREF'が提供されています)に' 'がありますか? –

+0

あなたは 'routerLink'とリンクしていますか? htmlの先頭に ''がありますか? – joaumg

+0

@GünterZöchbauer聞いてよかった! はindex.htmlの先頭にあります –

答えて

0

ルーティングの遅延ロードがあります。あなたはそれについてここで読むことができますlazy-loading-1lazy-loading-2