2

in Angular 1 the application would take 1-3 seconds on initial load to get all resources and initialize. After that, navigating to different routes would just append #tab1 to the url and instantly switch to that route.

Is that still possible in Angular2?

Because following examples on angular.io each route re-loads entire app which takes 1-3 seconds while looking at a blank screen with a loader. It does not append a #path. Should I be using a different router to go back to that speed?

index.html

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

here is my router config:

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);
Sonic Soul
  • 23,855
  • 37
  • 130
  • 196
  • There is something substantially wrong with your setup if this is happening. Can you try to switch to `HashLocationStrategy`? Do you have a `` in the `` element (or `APP_BASE_HREF` provided)? – Günter Zöchbauer Dec 09 '16 at 16:29
  • Are you linking with `routerLink` ? Do you have `` in the head of the html ? – joaumg Dec 09 '16 at 16:29
  • @GünterZöchbauer good to hear! is located in head of index.html – Sonic Soul Dec 09 '16 at 16:30
  • Please try http://stackoverflow.com/questions/36861628/location-and-hashlocationstrategy-stopped-working-in-beta-16 – Günter Zöchbauer Dec 09 '16 at 16:31
  • thanks it's definitely faster but all the routing is screwed up. as in, the path in address bar is one click behind and the tabs are not selecting correctly. – Sonic Soul Dec 09 '16 at 16:37
  • a lot of crazy things are happening. some paths still reload entire page and also other tabs in chrome! – Sonic Soul Dec 09 '16 at 16:40

1 Answers1

0

There is lazy-loading of routing . You can read about that here lazy-loading-1 and lazy-loading-2

Elvin Garibzade
  • 475
  • 4
  • 12