Closed robie2011 closed 7 years ago
It seems angular team changed something in the @NgModule
directive. I didn't tried this version yet.
I'm at work currently. Can you try to export the config and then use it?
config.ts
import { TranslateConfig } from 'angular2-translator/angular2-translator'
export const MyTranslateConfig = new TranslateConfig({...});
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
// import { LanguageComponent } from './language.components';
import { TranslatorModule, TranslateConfig, TranslateService, TranslatePipe } from 'angular2-translator/angular2-translator';
import { MyTranslateConfig } from 'config';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
TranslatorModule
],
providers: [
{ provide: TranslateConfig, useValue: MyTranslateConfig },
TranslatePipe,
TranslateService
],
bootstrap: [AppComponent]
})
export class AppModule { }
WARNING: this is written in the editor and never compiled. Maybe I dont remember the syntax correctly. Please check the syntax :smile:
may be this file has to be changed as well: https://github.com/tflori/angular2-translator/blob/master/angular2-translator.ts
I can do this in the evening.
I removed alle providers from @NgModule
and get this error
ERROR in Error encountered resolving symbol values statically. Calling function 'TranslateConfig', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol TranslatorModule in /Users/robert/repository/nextlevel17/nl2017-client/node_modules/angular2-translator/angular2-translator.ts, resolving symbol TranslatorModule in /Users/robert/repository/nextlevel17/nl2017-client/node_modules/angular2-translator/angular2-translator.ts
Maybe it would help to replace useValue: new
with useFactory: () => new
?
I'm not familiar with npm packages. I tried to change the source code in node_modules for testing purpose. But I'm getting this 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 29:49 in the original .ts file), resolving symbol TranslatorModule in /Users/robert/repository/nextlevel17/nl2017-client/node_modules/angular2-translator/angular2-translator.ts
As I thought - this libray has the same way (create a new object inside providers: {}
property from @NgModule
) of providing the config. This seems not to work anymore. I will investigate in the evening.
Sorry, I can't reproduce it. I see you used angular-cli. So you also copied the code to your source folder right?
Maybe you can try download the source from this branch and try it with the code from there - may be it works. But anyway: I don't support angular-cli - especially because it is still beta
yes, I did.
I see. This must be an issue with angular-cli.
If this fix helps I can publish 1.3.1 from it - if not it would be nice if you find a solution and post it here. Thanks in advance!
I have this strage error message, when I run
npm start
Note: When I change a source file, then webpack will be recompiled successfully.
any ideas? node : v7.5.0 npm: 4.2.0 os: mac os 10.12.3
Full log
package.json
app.module.ts