fix(ivy): set LOCALE_ID when using the injector (#31566)

In `BrowserModule` the value of `LOCALE_ID` is defined in the `APPLICATION_MODULE_PROVIDERS` after `APP_INITIALIZER` has run.
This PR ensures that `LOCALE_ID` is also set for ivy at the same moment which allows the application to fetch the locale from a backend (for example).

Fixes #31465

FW-1436 #resolve

PR Close #31566
This commit is contained in:
Olivier Combe
2019-07-15 15:28:07 +02:00
committed by Andrew Kushnir
parent 40a0666651
commit 5296c04f61
11 changed files with 103 additions and 72 deletions

View File

@ -343,6 +343,21 @@ class SomeComponent {
expect(getLocaleId()).toEqual('ro');
});
it('should wait for APP_INITIALIZER to set providers for `LOCALE_ID`', async() => {
let locale: string = '';
const promise = Promise.resolve().then(() => { locale = 'fr-FR'; });
const testModule = createModule({
providers: [
{provide: APP_INITIALIZER, useValue: () => promise, multi: true},
{provide: LOCALE_ID, useFactory: () => locale}
]
});
const app = await defaultPlatform.bootstrapModule(testModule);
expect(app.injector.get(LOCALE_ID)).toEqual('fr-FR');
});
});
describe('bootstrapModuleFactory', () => {