Snippet from my angular session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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