在路由中使用哈希的Angular2失败

时间:2017-02-20 07:31:03

标签: angular angular2-routing

来自文档https://angular.io/docs/ts/latest/guide/router.html#!#browser-url-styles

我添加了

 const appRoutes: Routes = [
  { path: '', redirectTo: 'login', pathMatch: 'full' },
  { path: 'login', component: LoginComponent},
  { path: 'reset-password', component: ResetPasswordComponent },
    { path: '**', component: PageNotFoundComponent }
  ];

 @NgModule({
  imports: [
     RouterModule.forRoot(appRoutes, { useHash: true }) //added this useHash
   ],
   exports: [RouterModule],
    providers: []
    } )
    export class AppRoutingModule { }

但是我现在收到错误node_modules/@angular/router/index"' has no exported member 'ROUTER_PROVIDERS'并且错误指向useHash上的行

这些是APP模块的进口

imports: [
 BrowserModule,
 FormsModule,
 HttpModule,
 AppRoutingModule, //CONTAINS THE ABOVE ROUTING
 AngularFireModule.initializeApp(firebaseConfig)

],

我错在哪里或者我需要为此工作添加更多内容

1 个答案:

答案 0 :(得分:-1)

试试这个:

imports: [
  BrowserModule,
  FormsModule,
  HttpModule,
  AngularFireModule.initializeApp(firebaseConfig),
  AppRoutingModule,
],