* Creates an instance of an `@NgModule` for a given platform. * * @usageNotes * ### Simple Example * * ```ts * @NgModule({ * imports: [BrowserModule] * }) * class MyModule {} * * let moduleRef = platformBrowser().bootstrapModule(MyModule); * ``` *
(
moduleType: Type<M>,
compilerOptions:
| (CompilerOptions &
BootstrapOptions & {applicationProviders?: Array<Provider | EnvironmentProviders>})
| Array<
CompilerOptions &
BootstrapOptions & {applicationProviders?: Array<Provider | EnvironmentProviders>}
> = [],
)
| 89 | * |
| 90 | */ |
| 91 | bootstrapModule<M>( |
| 92 | moduleType: Type<M>, |
| 93 | compilerOptions: |
| 94 | | (CompilerOptions & |
| 95 | BootstrapOptions & {applicationProviders?: Array<Provider | EnvironmentProviders>}) |
| 96 | | Array< |
| 97 | CompilerOptions & |
| 98 | BootstrapOptions & {applicationProviders?: Array<Provider | EnvironmentProviders>} |
| 99 | > = [], |
| 100 | ): Promise<NgModuleRef<M>> { |
| 101 | const options = optionsReducer({}, compilerOptions); |
| 102 | setModuleBootstrapImpl(); |
| 103 | const wasDestroyed = this._destroyed; |
| 104 | return compileNgModuleFactory(this.injector, options, moduleType).then((moduleFactory) => { |
| 105 | if (!wasDestroyed && this._destroyed) { |
| 106 | const moduleRef = createNgModuleRefWithProviders( |
| 107 | moduleFactory.moduleType, |
| 108 | this.injector, |
| 109 | [], |
| 110 | ); |
| 111 | moduleRef.destroy(); |
| 112 | return moduleRef; |
| 113 | } |
| 114 | |
| 115 | return this.bootstrapModuleFactory(moduleFactory, options); |
| 116 | }); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Registers a listener to be called when the platform is destroyed. |
no test coverage detected