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

Method _attachContainer

src/cdk/dialog/dialog.ts:238–270  ·  view source on GitHub ↗

* Attaches a dialog container to a dialog's already-created overlay. * @param overlay Reference to the dialog's underlying overlay. * @param config The dialog configuration. * @returns A promise resolving to a ComponentRef for the attached container.

(
    overlay: OverlayRef,
    dialogRef: DialogRef<R, C>,
    config: DialogConfig<D, DialogRef<R, C>>,
  )

Source from the content-addressed store, hash-verified

236 * @returns A promise resolving to a ComponentRef for the attached container.
237 */
238 private _attachContainer<R, D, C>(
239 overlay: OverlayRef,
240 dialogRef: DialogRef<R, C>,
241 config: DialogConfig<D, DialogRef<R, C>>,
242 ): DialogContainer {
243 const userInjector = config.injector || config.viewContainerRef?.injector;
244 const providers: StaticProvider[] = [
245 {provide: DialogConfig, useValue: config},
246 {provide: DialogRef, useValue: dialogRef},
247 {provide: OverlayRef, useValue: overlay},
248 ];
249 let containerType: Type<DialogContainer>;
250
251 if (config.container) {
252 if (typeof config.container === 'function') {
253 containerType = config.container;
254 } else {
255 containerType = config.container.type;
256 providers.push(...config.container.providers(config));
257 }
258 } else {
259 containerType = CdkDialogContainer;
260 }
261
262 const containerPortal = new ComponentPortal(
263 containerType,
264 config.viewContainerRef,
265 Injector.create({parent: userInjector || this._injector, providers}),
266 );
267 const containerRef = overlay.attach(containerPortal);
268
269 return containerRef.instance;
270 }
271
272 /**
273 * Attaches the user-provided component to the already-created dialog container.

Callers 1

openMethod · 0.95

Calls 3

pushMethod · 0.65
attachMethod · 0.65
createMethod · 0.45

Tested by

no test coverage detected