Skip to content

feat(bottom-sheet): Allow injector to be passed in for BottomSheet #31951

@shahraship

Description

@shahraship

Feature Description

In https://material.angular.dev/components/dialog/api#MatDialogConfig we're able to pass in an injector

However, in https://material.angular.dev/components/bottom-sheet/api#MatBottomSheetConfig we're not able to pass in an injector.

It would be nice if we're able to do this such that we can dynamically inject tokens for use in components

Use Case

private myInjection = inject(Injector);
private dialog = inject(MatDialog);
private bottomSheet = inject(MatBottomSheet);

...
const customInjector = Injector.create({
      providers: [
        { provide: MY_CUSTOM_DATA, useValue: { myKey: 'myVal' } }
      ],
      parent: this.myInjection
    });

if (openDialog) {
  const dialogConfig: MatDialogConfig = {
     ...config,
     injector: customInjector
  };
  this.dialog.open(DialogReference, dialogConfig);
} else {
  const sheetConfig: MatBottomSheetConfig = {
     ...config,
     injector: customInjector // <--- this is not available
  };
  this.bottomSheet.open(SheetReference, sheetConfig);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/bottom-sheetfeatureThis issue represents a new feature or feature request rather than a bug or bug fixgood first issueThis issue is a good place to start for first time contributors to the projecthelp wantedThe team would appreciate a PR from the community to address this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions