MCPcopy Create free account
hub / github.com/angular/angular / bootstrapModule

Method bootstrapModule

packages/core/src/platform/platform_ref.ts:91–117  ·  view source on GitHub ↗

* 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>}
        > = [],
  )

Source from the content-addressed store, hash-verified

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.

Callers 15

bootstrapFunction · 0.80
bootstrap_spec.tsFile · 0.80
bootstrapAppFunction · 0.80
main.tsFile · 0.80
bootstrapAppFunction · 0.80
bootstrap_spec.tsFile · 0.80
ng_module_spec.tsFile · 0.80

Calls 7

optionsReducerFunction · 0.90
setModuleBootstrapImplFunction · 0.90
compileNgModuleFactoryFunction · 0.90
thenMethod · 0.65
destroyMethod · 0.65

Tested by

no test coverage detected