如何在Angular2 compiler/cli ngc命令中使用RouterModule.forRoot()

Pie*_*t K 5 angular2-routing angular2-compiler angular

假设我有以下appRoutingModule:

export const routes: Route[] = [
  {
    path: '',
    component: ApplicationlistComponent
  }
];

@NgModule( {
  imports: [ ApplicationsModule, RouterModule.forRoot( routes ) ],
  exports: [ RouterModule ],
  declarations: [ApplicationlistComponent]
} )
export class AppRoutingModule {
}
Run Code Online (Sandbox Code Playgroud)

使用ngc cli命令编译时,会出现以下错误:

Error: Error encountered resolving symbol values statically. Calling function 'RouterModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppRoutingModule in C:/git/mxt-frontend/landing-page-client/src/client/app/app-routing.module.ts, resolving symbol AppRoutingModule in C:/git/mxt-frontend/landing-page-client/src/client/app/app-routing.module.ts
Run Code Online (Sandbox Code Playgroud)

我尝试将它放在导出的const中:

export const routerModule =  RouterModule.forRoot( routes );
Run Code Online (Sandbox Code Playgroud)

但是这会产生这个错误:

Error: Error encountered resolving symbol values statically
Run Code Online (Sandbox Code Playgroud)

让这个工作的解决方法/修复方法是什么?如果我无法将其传递给RouterModule,如何定义我的路由?

我正在使用版本:

"@angular/compiler": "~2.4.0",
"@angular/compiler-cli": "~2.4.0",
"@angular/platform-server": "~2.4.0",
"@angular/router": "~3.4.0"
Run Code Online (Sandbox Code Playgroud)

等等

Pie*_*t K 2

我通过将 Angular 恢复到版本 2.3.1 解决了这个问题。看起来它在 2.4.0 版本中被破坏了..