MCPcopy Create free account
hub / github.com/angular/components / load

Method load

src/cdk/private/style-loader.ts:46–68  ·  view source on GitHub ↗

* Loads a set of styles. * @param loader Component which will be instantiated to load the styles.

(loader: Type<unknown>)

Source from the content-addressed store, hash-verified

44 * @param loader Component which will be instantiated to load the styles.
45 */
46 load(loader: Type<unknown>): void {
47 // Resolve the app ref lazily to avoid circular dependency errors if this is called too early.
48 const appRef = (this._appRef = this._appRef || this._injector.get(ApplicationRef));
49 let data = appsWithLoaders.get(appRef);
50
51 // If we haven't loaded for this app before, we have to initialize it.
52 if (!data) {
53 data = {loaders: new Set(), refs: []};
54 appsWithLoaders.set(appRef, data);
55
56 // When the app is destroyed, we need to clean up all the related loaders.
57 appRef.onDestroy(() => {
58 appsWithLoaders.get(appRef)?.refs.forEach(ref => ref.destroy());
59 appsWithLoaders.delete(appRef);
60 });
61 }
62
63 // If the loader hasn't been loaded before, we need to instatiate it.
64 if (!data.loaders.has(loader)) {
65 data.loaders.add(loader);
66 data.refs.push(createComponent(loader, {environmentInjector: this._environmentInjector}));
67 }
68 }
69}

Callers 15

constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorFunction · 0.80
constructorMethod · 0.80

Calls 7

setMethod · 0.80
getMethod · 0.65
destroyMethod · 0.65
deleteMethod · 0.65
pushMethod · 0.65
createComponentFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected