【发布时间】:2016-10-12 01:16:33
【问题描述】:
在运行 i18n 时,我还遇到了著名的错误“遇到静态解析符号值时出错。不支持函数调用。考虑将函数或 lambda 替换为对导出函数的引用,解析符号”。 我已经做了很多研究,而且我没有使用 lambda 函数。当我将以下导入语句添加到我的基本模块时会发生这种情况:
export const mapsConfig = new LazyMapsAPILoaderConfig();
mapsConfig.apiKey = 'xyz';
// ... below is in import list
BingMapsModule.forRoot(config),
我正在使用 ng2-bingmaps,我也为它做出了贡献:https://github.com/youjustgo/ng2-bingmaps
奇怪的是,ng2-bingmaps 中的 JS 代码是什么并不重要。如果我删除所有 .js 文件,我仍然会收到同样的错误!因此,它必须是 ng2-bingmaps core.d.ts 中的内容,如下所示:
/**
* 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)时,它可以工作。
我检查了 ng2-bingmaps 中的所有提供程序,它们都没有在装饰器中具有 lambda 函数。
我的基本模块定义:
@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
]
})
【问题讨论】:
-
显示更多基本模块。很难很好地了解您如何在上下文中使用
BingMapsModule。
标签: javascript angular typescript