Reputation: 310
I want to load some configuration for OAuth before the application loads. I've been following this post but I'm getting an error in my app.main.ts when i try to set the environment variables:
cannot find name environment
Here is my app.main.ts:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { ProdConfig } from './blocks/config/prod.config';
import { HelloworldAppModule } from './app.module';
ProdConfig();
if (module['hot']) {
module['hot'].accept();
}
(async () => {
const response = await fetch ("../../../../../config.json")
const config = await response.json();
environment['issuer'] = config.issuer;
environment['redirectUri'] = config.redirectUri;
environment['clientId'] = config.clientId;
platformBrowserDynamic()
.bootstrapModule(HelloworldAppModule, { preserveWhitespaces: true })
// eslint-disable-next-line no-console
.then(() => console.log('Application started'))
.catch(err => console.error(err));
})();
How do I set the environment from app.main.ts?
Upvotes: 1
Views: 1959
Reputation: 222582
In order to use environment variables, you need to import
import Environment from "./Environment.ts"
Upvotes: 1