没有导出的成员' PreLoadAllModules',角度为2?

时间:2017-02-09 06:32:28

标签: angular typescript

我正在创建一个演示应用程序但是遇到了这个错误。我试图解决它但是不能。请告诉我我做错了什么?我认为来自Angular路由器包的PreloadAllModules令牌。

错误的完整描述是:

app / app-routing.module.ts(33,15):错误TS2305:模块'" / home / angular2 / test / node_modules / @ angular / router / index&#34 ;'没有导出的成员' PreLoadAllModules'。

代码如下:

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 个答案:

答案 0 :(得分:0)

@angular/router/src/router_preloader.ts此类仅存在于Angular 2.1.x或更高版本中,请确保使用最新的Angular版本。

来源:

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

答案 1 :(得分:0)

简单的拼写错误我相信,正确的输入是:

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