In my Angular application (version 19), I have a provideAppInitializer like this:
export const appConfig: ApplicationConfig = {
providers: [
...
provideAppInitializer(intializeAppFn),
..
]
};
And the intializeAppFn loads config from a service:
const intializeAppFn = () => {
const configService = inject(AppConfigService);
return configService.loadConfig();
};
What I would need is to add another provider which requires values from the configService.getConfig().
I want to add the provider shown here:
provideMatomo({
siteId:// value from the config service
trackerUrl:// value from the config service
})
How do I properly chain for multiple initialize functions?
UPDATE
Solution which I tried so far, but the provider provideMatomo is not initialized
const initializeMatomoFn = () => {
const configService = inject(AppConfigService);
return configService.loadConfig().then(() => {
const config = configService.getConfig();
return provideMatomo({
siteId: '',
trackerUrl: config.MATOMO_BASE_URL,
},withRouter());
});
};
provideAppInitializer(initializeMatomoFn)