Skip to content

Instantly share code, notes, and snippets.

@nirkaufman
Last active August 13, 2021 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nirkaufman/3ae3a8685b3527ff91fc3a996647da25 to your computer and use it in GitHub Desktop.
Save nirkaufman/3ae3a8685b3527ff91fc3a996647da25 to your computer and use it in GitHub Desktop.
Snippet from my angular session
async function bootstrap() {
const config = await fetch('http://localhost:3000/config').then( res => res.json() );
// You can provide static providers to the created platform
const browserPlatform = platformBrowserDynamic([
{ provide: ConsoleLogger }
]);
// After bootstrapping your module you can use thק appModuleRef to configure
// The module injector, and get access to this module components
// example: `const applicationRef = appModuleRef.injector.get<ApplicationRef>(ApplicationRef);`
const appModuleRef: NgModuleRef<AppModule> = await browserPlatform.bootstrapModule(AppModule);
// It is possible to bootstrap modules depend on certain condition
if(config.alerts) {
await browserPlatform.bootstrapModule(AlertModule, {
ngZone: 'noop'
});
}
}
bootstrap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment