假设我有以下 appRoutingModule:
export const routes: Route[] = [
{
path: '',
component: ApplicationlistComponent
}
];
@NgModule( {
imports: [ ApplicationsModule, RouterModule.forRoot( routes ) ],
exports: [ RouterModule ],
declarations: [ApplicationlistComponent]
} )
export class AppRoutingModule {
}
使用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
我尝试将其放在导出的 const 中:
export const routerModule = RouterModule.forRoot( routes );
但这会给出这个错误:
Error: Error encountered resolving symbol values statically
什么是解决方法/解决方法来让它工作?如果我无法将路由传递给 RouterModule,如何定义路由?
我正在使用版本:
"@angular/compiler": "~2.4.0",
"@angular/compiler-cli": "~2.4.0",
"@angular/platform-server": "~2.4.0",
"@angular/router": "~3.4.0"
等等