Skip to content

help(MatDatePicker): Ability to Conditionally Show/Hide mat-datepicker-actions #25122

Closed
@penrodlol

Description

@penrodlol

What are you trying to do?

When creating a mat-datepicker component we have the following example:

<mat-datepicker #picker>
  <mat-datepicker-actions *ngIf="prop$ | async">
     ...
  </mat-datepicker-actions>
</mat-datepicker>

Within this datepicker's header, there's a mat-slide-toggle that updates the props$ state to T/F. However, when updated, the mat-datepicker-actions remain visible within the template...

Is there a way to ensure the actions can be shown/removed without having to close and repoen the datepicker popover?

What troubleshooting steps have you tried?

  1. Force change detection via ChangeDetectorRef.
  2. Utilize the registerActions and removeActions methods on MatDatepicker.

Reproduction

https://stackblitz.com/edit/components-issue-xiz8hd?file=src/app/example-component.ts

Environment

  • Angular: 13
  • CDK/Material: 13
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/datepicker

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions