-
Notifications
You must be signed in to change notification settings - Fork 69
WebpackTranslateLoader example in the document is not accurate for Angular 6 /Rxjs 6 #47
Comments
Thanks @gwelr it works now, i get this warning any idea? WARNING in ./src/app/loaders/webpack-translate-loader.ts |
Same issue for me. |
Just use import instead of System.import().
tsconfig module should be "esnext" instead of "ES2015".
|
@lutzleonhardt thanks, it works now with no warnings |
Not sure about the impact. Maybe someone else know whether it's safe to use esnext instead of es2015 regarding the browser compatibility. |
The way I found it to work in Angular 7:
It looks like the returned object is added under the default key |
This works fine with Angular 8 & rxjs 6.4.0 import { TranslateLoader } from '@ngx-translate/core';
import { from } from 'rxjs/index';
/** @desc Loads translations files in `src/assets/i18n/${lang}.json` */
export class WebpackTranslateLoader implements TranslateLoader {
getTranslation(lang: string) {
return from(import(`../../../../src/assets/i18n/${lang}.json`));
}
} |
With the release of rxjs 6, the imports and creation of Observables have changed. There is no more fromPromise which has been replaced by from
This is how I updated the code to have it working:
The text was updated successfully, but these errors were encountered: