Skip to content

Instantly share code, notes, and snippets.

@nirkaufman
Last active Aug 13, 2021
Embed
What would you like to do?
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