0
votes

I am creating a demo app but got this error.I tried to solve it but can't.Please suggest me what I am doing wrong? I think the PreloadAllModules token from the Angular router package.

The complete description of error is:

app/app-routing.module.ts(33,15): error TS2305: Module '"/home/angular2/test/node_modules/@angular/router/index"' has no exported member 'PreLoadAllModules'.

The code is given below:

import { RouterModule, Routes ,
         Router , ActivatedRoute,
         PreLoadAllModules         }    from '@angular/router'; 
import { NgModule                  }    from '@angular/core';
import { DashboardComponent        }    from './dashboard.component';
import { TestComponent             }    from './test.component';
import { ContactComponent          }    from './component/contact.component';
import { DirectiveExampleComponent }    from './component/directive.exp.component';
import { PowerBoosterComponent     }    from './component/power-booster.component';
import { PageNotFound              }    from './component/page.not.found.component';

export const routes: Routes = [
  { path:  'dashboard',                  component: DashboardComponent },
  { path:  'test',                       component: TestComponent },
  { path:  'contactus',                  component: ContactComponent },
  { path:  'directive',                  component: DirectiveExampleComponent },
  { path:  'pipeexamples',               component: PowerBoosterComponent,data:{name:'shubham',id:1} },
  { path:  '', redirectTo: '/dashboard', pathMatch: 'full' },
  { path:  '**',                         component: PageNotFound},

];

@NgModule({
  imports:    [ RouterModule.forRoot(routes,{ preloadingStrategy:PreLoadAllModules }) ],
  exports:    [ RouterModule ],
})
export class AppRoutingModule {}
2

2 Answers

0
votes

@angular/router/src/router_preloader.ts this class only exist in Angular 2.1.x or above, please make sure you using latest Angular version.

sources:

https://github.com/angular/angular/blob/2.1.x/modules/@angular/router/src/router_preloader.ts#L44-L48

0
votes

Simple mispelling I believe, the correct import is:

import { PreloadAllModules } from '@angular/router/router';