Skip to content

feat(bottom-sheet): Access container instance elementRef #28714

Open
@ibrahimgabsi

Description

@ibrahimgabsi

Which @angular/* package(s) are relevant/related to the feature request?

@angular/material/bottom-sheet

Description

Consider this service:

....

@Injectable({
  providedIn: 'root',
})
export class MyBottomSheetService {
  private bottomSheet = inject(MatBottomSheet);

  private bottomSheetRef?: MatBottomSheetRef;

  open(templateRef: TemplateRef<unknown>): void {
     this.bottomSheetRef = this.bottomSheet.open(templateRef);
  }
}

This service opens bottom sheets with dynamic content using the given template.
Once it's opened, we want to access to mat bottom sheet container or its DOM content using the bottomSheetRef in order to execute a generic behavior based in the projected content.

Proposed solution

bottomSheetRef returned by the open() method gives access to containerInstance property.

Convert elementRef of containerInstance from private to public property.

Alternatives considered

No alternatives considered...

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: material/bottom-sheet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions