I know I'm not the only one having questions regarding this term. But the angular guys have about 23 questions regarding this term. I tried a lot of different things. One is important: I tried it the same way they do it for @angular/http
(exporting a bare factory function).
Fact is: it works - the code is not incorrect. But when I try to import the module I get this error:
ERROR in Error encountered resolving symbol values statically. Calling function
'TranslatorConfig', function calls are not supported. Consider replacing the
function or lambda with a reference to an exported function, resolving symbol
TranslatorModule.forRoot
When I run ng serve and touch the file after this error it recompiles without an error. But what ever I try to build (ng build -e prod --aot false
) I get this error and the build stops. I also get this error when I set "strictMetadataEmit": true
in tsconfig.json. I have a TranslatorModule.metadata.json
- this will not be the error.
Why it does not work? What does this error message mean in detail? What is the symbol value and why it has to be statically? How to get it to work?
For testing you can just install angular2-translator@2.0.0-alpha3. You can find the code on github: https://github.com/tflori/angular2-translator/tree/2.0
I just tried with these exported functions and different providers like below.
export function createTranslatorConfig(config: any = {}) {
return new TranslatorConfig(config);
}
export function createTranslator(translatorContainer: TranslatorContainer, module: string) {
return translatorContainer.getTranslator(module);
}
// ...
export class TranslatorModule {
public static forRoot(config: any = {}, module: string = "default"): ModuleWithProviders {
return {
ngModule: TranslatorModule,
providers: [
{ provide: "TranslatorConfigOptions", useValue: config },
{ provide: TranslatorConfig, useFactory: createTranslatorConfig, deps: [ "TranslatorConfigOptions" ] },
{ provide: "TranslatorModuleName", useValue: module },
{
provide: Translator,
useFactory: createTranslator,
deps: [ TranslatorContainer, "TranslatorModuleName" ],
},
],
};
}
}
The result is just another error message (now 'emakeDecorator' for symbol NgModule has a problem: ERROR in Error encountered resolving symbol values statically. Calling function 'ɵmakeDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol NgModule