Angular – Importing module causes lambda error

Home / Uncategorized / Angular – Importing module causes lambda error

Question:
I’m writing a library and I got everything working apart from integrating the library with an actual app. I get a lambda error but I cannot figure out why this is happening.

Here is the error:

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 194:50 in the original .ts file), resolving symbol NgModule in //ng/lib-ng/node_modules/@angular/core/core.d.ts, resolving symbol Components in //ng/lib-ng/dist/modules/components.module.d.ts, resolving symbol Components in //ng/lib-ng/dist/modules/components.module.d.ts

And here’s the module that throws it:
providers.ts
export const COMPONENTS_PROVIDERS: any[] = [
BreadcrumbsUtils,
ModalApi,
NotificationsApi,
SiteHeaderApi
];
components.module.ts
import {COMPONENTS_PROVIDERS} from ‘../components/providers’;

@NgModule({
imports: [
BreadcrumbsModule,
CheckboxModule,
CheckboxesModule,
DataListModule,
DropdownModule,
DropdownSelectModule,
FileUploaderModule,
ModalModule,
NotificationsModule,
SearchInputModule,
SelectModule,
SelectMultipleModule,
SiteFooterModule,
SiteHeaderModule,
SwitchModule
],
exports: [
BreadcrumbsModule,
CheckboxModule,
CheckboxesModule,
DataListModule,
DropdownModule,
DropdownSelectModule,
FileUploaderModule,
ModalModule,
NotificationsModule,
SearchInputModule,
SelectModule,
SelectMultipleModule,
SiteFooterModule,
SiteHeaderModule,
SwitchModule
]
})

export class Components {

public static forRoot() {

return {
ngModule: Components,
providers: COMPONENTS_PROVIDERS
};
}
}
The AppModule that is used to test the lib:import {Components} from ‘../../lib-ng’;

@NgModule({
imports: [

// Throws error
Components.forRoot()

// Importing it without calling forRoot throws the same error
Components
],
declarations: [
AppComponent
],
schemas: [
NO_ERRORS_SCHEMA
],
bootstrap: [
AppComponent
]
})

export class AppModule {}
Why am I getting this error?


Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *