Angular 2.0.2 - 在静态解析符号值时遇到错误 [英] Angular 2.0.2 - Error encountered resolving symbol values statically
问题描述
我也遇到了一个着名的错误Error遇到静态解析符号值。不支持函数调用。在运行i18n时,考虑用引用函数替换函数或lambda,解析符号。
我已经做了很多研究,而且我没有使用lambda函数。当我将以下import语句添加到我的基本模块时会发生这种情况:
I'm also running into the famous error "Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol ", when running i18n. I've already done a lot of research, and I'm not using a lambda function. It happens when I add the following import statement to my base module:
export const mapsConfig = new LazyMapsAPILoaderConfig();
mapsConfig.apiKey = 'xyz';
// ... below is in import list
BingMapsModule.forRoot(config),
我正在使用ng2-bingmaps,我也参与其中: https:// github.com/youjustgo/ng2-bingmaps
I'm using ng2-bingmaps, which I've contributed to as well: https://github.com/youjustgo/ng2-bingmaps
奇怪的是,ng2-bingmaps中的JS代码无关紧要。如果我删除所有.js文件,我仍然会得到相同的错误!因此,它必须是ng2-bingmaps core.d.ts中的内容,如下所示:
The weird thing is that it does not matter what the JS code is in ng2-bingmaps. If I remove all .js files, I still get the same error! So, it must be something in the ng2-bingmaps core.d.ts which looks like this:
/**
* ng2-bingmaps - Angular 2 components for Bing Maps
* @version v0.2.0
* @link https://github.com/youjustgo/ng2-bingmaps
* @license MIT
*/
import { ModuleWithProviders } from '@angular/core';
import { LazyMapsAPILoaderConfig } from './services/maps-api-loader/lazy-maps-api-loader';
export * from './directives';
export * from './services';
export declare const NG2_BINGMAPS_PROVIDERS: any[];
/**
* The ng2-bing-maps core module. Contains all Directives/Services/Pipes
* of the core module. Please use `BingMapsModule.forRoot(config)` in your app module.
*
* @experimental
*/
export declare class BingMapsModule {
static forRoot(config: LazyMapsAPILoaderConfig): ModuleWithProviders;
}
当我只导入BingMapsModule(没有forRoot)时,它可以工作。
When I just import BingMapsModule (without the forRoot), it works.
我检查了ng2-bingmaps中的所有提供者,并且没有人在装饰器中有lambda函数。
I have checked all providers in ng2-bingmaps, and none of them have lambda functions inside the decorators.
我的基本模块定义:
@NgModule({
imports: [
// browser module, required to load in browser
BrowserModule,
// routing
RouterModule.forRoot(routes),
// angular forms
FormsModule,
// ng2-bingmaps
BingMapsModule.forRoot(mapsConfig),
// ng-bootstrap
NgbModule,
// http
HttpModule,
// Angulartics2
// Angulartics2Module.forRoot(),
// our custom modules for certain parts of our app
CreateBookingModule,
CommonModule
],
declarations: [
// all our components
],
bootstrap: [ ClientApp ],
providers: [
// our services
]
})
推荐答案
最后我已经解决了,感谢@peeskillet的回答。
In the end I've resolved it, thanks the @peeskillet for the answer.
- 使用对象文字在而不是配置对象。
- ng2-bingmaps不包含所需的* .metadata.json文件;每个.d.ts文件显然都需要这个。
这篇关于Angular 2.0.2 - 在静态解析符号值时遇到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!