Skip to content

bug(timepicker): cannot disable timepicker from template #30061

Closed
@f-mon

Description

@f-mon

Description

The disable input in timepicker.ts component is protected so angular compiler reports an error if you try to diable it from template:

<mat-form-field>
  <mat-label>Pick a time</mat-label>
  <input matInput [matTimepicker]="picker" disabled >
  <mat-timepicker-toggle matIconSuffix [for]="picker"/>
  <mat-timepicker #picker/>
</mat-form-field>

compiling will report:


Error: src/example/timepicker-overview-example.html:4:44 - error TS2445: Property 'disabledInput' is protected and only accessible within class 'MatTimepickerInput<D>' and its subclasses.

4   <input matInput [matTimepicker]="picker" disabled >
                                             ~~~~~~~~

  src/example/timepicker-overview-example.ts:10:16
    10   templateUrl: 'timepicker-overview-example.html',
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reproduction

StackBlitz link: https://stackblitz.com/edit/tn1pxy?file=src%2Fexample%2Ftimepicker-overview-example.html

Expected Behavior

should be possible to disable the timepicker field from template

Actual Behavior

it reports a compiling error

Environment

  • Angular: 19
  • CDK/Material: 19

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions