diff --git a/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.html b/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.html index 1b1f68e136d9..e0719977acca 100644 --- a/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.html +++ b/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.html @@ -1,15 +1,13 @@
- - + +
- + - - Personal data - + Personal data Type your name and age account_circle @@ -18,22 +16,19 @@ First name - + Age - + - - + - + - - Destination - + Destination Type the country name map @@ -42,15 +37,13 @@ Country - + - - Day of the trip - + Day of the trip Inform the date you wish to travel date_range @@ -59,7 +52,7 @@ Date - + diff --git a/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.ts b/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.ts index bfec84229ecc..c0d09f8e267e 100644 --- a/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.ts +++ b/src/components-examples/material/expansion/expansion-expand-collapse-all/expansion-expand-collapse-all-example.ts @@ -1,11 +1,11 @@ -import {Component, ViewChild} from '@angular/core'; -import {MatAccordion, MatExpansionModule} from '@angular/material/expansion'; +import {ChangeDetectionStrategy, Component, viewChild} from '@angular/core'; +import {MatButtonModule} from '@angular/material/button'; +import {provideNativeDateAdapter} from '@angular/material/core'; import {MatDatepickerModule} from '@angular/material/datepicker'; -import {MatInputModule} from '@angular/material/input'; +import {MatAccordion, MatExpansionModule} from '@angular/material/expansion'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatIconModule} from '@angular/material/icon'; -import {MatButtonModule} from '@angular/material/button'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** * @title Accordion with expand/collapse all toggles @@ -24,7 +24,8 @@ import {provideNativeDateAdapter} from '@angular/material/core'; MatInputModule, MatDatepickerModule, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExpansionExpandCollapseAllExample { - @ViewChild(MatAccordion) accordion: MatAccordion; + accordion = viewChild.required(MatAccordion); } diff --git a/src/components-examples/material/expansion/expansion-harness/expansion-harness-example.ts b/src/components-examples/material/expansion/expansion-harness/expansion-harness-example.ts index 72b8f2f2890a..55c2bb6c6d51 100644 --- a/src/components-examples/material/expansion/expansion-harness/expansion-harness-example.ts +++ b/src/components-examples/material/expansion/expansion-harness/expansion-harness-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component} from '@angular/core'; import {MatExpansionModule} from '@angular/material/expansion'; /** @@ -9,5 +9,6 @@ import {MatExpansionModule} from '@angular/material/expansion'; templateUrl: 'expansion-harness-example.html', standalone: true, imports: [MatExpansionModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExpansionHarnessExample {} diff --git a/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.html b/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.html index 552cd3d161ca..63f9dff1eb82 100644 --- a/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.html +++ b/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.html @@ -1,27 +1,20 @@ - - + + - + - - This is the expansion title - - - This is a summary of the content - + This is the expansion title + This is a summary of the content

This is the primary content of the panel.

- - + + - - Self aware panel - + Self aware panel - Currently I am {{panelOpenState ? 'open' : 'closed'}} + Currently I am {{panelOpenState() ? 'open' : 'closed'}}

I'm visible because I am open

diff --git a/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.ts b/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.ts index c5acf05bc7be..6e733bc60d48 100644 --- a/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.ts +++ b/src/components-examples/material/expansion/expansion-overview/expansion-overview-example.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component, signal} from '@angular/core'; import {MatExpansionModule} from '@angular/material/expansion'; /** @@ -9,7 +9,8 @@ import {MatExpansionModule} from '@angular/material/expansion'; templateUrl: 'expansion-overview-example.html', standalone: true, imports: [MatExpansionModule], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExpansionOverviewExample { - panelOpenState = false; + readonly panelOpenState = signal(false); } diff --git a/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.html b/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.html index c69815f92c8e..cbeed271fb98 100644 --- a/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.html +++ b/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.html @@ -1,9 +1,7 @@ - + - - Personal data - + Personal data Type your name and age account_circle @@ -12,25 +10,23 @@ First name - + Age - + - + - + - + - - Destination - + Destination Type the country name map @@ -39,7 +35,7 @@ Country - + @@ -48,11 +44,9 @@ - + - - Day of the trip - + Day of the trip Inform the date you wish to travel date_range @@ -61,7 +55,7 @@ Date - + @@ -70,5 +64,4 @@ - diff --git a/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.ts b/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.ts index 8ee83a29202c..d0fe339da89d 100644 --- a/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.ts +++ b/src/components-examples/material/expansion/expansion-steps/expansion-steps-example.ts @@ -1,11 +1,11 @@ -import {Component} from '@angular/core'; -import {MatDatepickerModule} from '@angular/material/datepicker'; +import {ChangeDetectionStrategy, Component, signal} from '@angular/core'; import {MatButtonModule} from '@angular/material/button'; -import {MatInputModule} from '@angular/material/input'; +import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatDatepickerModule} from '@angular/material/datepicker'; +import {MatExpansionModule} from '@angular/material/expansion'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatIconModule} from '@angular/material/icon'; -import {MatExpansionModule} from '@angular/material/expansion'; -import {provideNativeDateAdapter} from '@angular/material/core'; +import {MatInputModule} from '@angular/material/input'; /** * @title Expansion panel as accordion @@ -24,19 +24,20 @@ import {provideNativeDateAdapter} from '@angular/material/core'; MatButtonModule, MatDatepickerModule, ], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class ExpansionStepsExample { - step = 0; + step = signal(0); setStep(index: number) { - this.step = index; + this.step.set(index); } nextStep() { - this.step++; + this.step.update(i => i + 1); } prevStep() { - this.step--; + this.step.update(i => i - 1); } } diff --git a/src/material/expansion/expansion.md b/src/material/expansion/expansion.md index fa68d2d27b2a..1f10152ddcb3 100644 --- a/src/material/expansion/expansion.md +++ b/src/material/expansion/expansion.md @@ -12,16 +12,16 @@ as the control for expanding and collapsing. This header may optionally contain header to align with Material Design specifications. - + By default, the expansion-panel header includes a toggle icon at the end of the header to indicate the expansion state. This icon can be hidden via the `hideToggle` property. + "region": "hide-toggle"}) --> #### Action bar @@ -29,15 +29,16 @@ Actions may optionally be included at the bottom of the panel, visible only when is in its expanded state. + #### Disabling a panel Expansion panels can be disabled using the `disabled` attribute. A disabled expansion panel can't be toggled by the user, but can still be manipulated programmatically. ### Accordion @@ -47,13 +48,15 @@ expansions state to be set independently of each other. When `multi="false"` (de panel can be expanded at a given time: ### Lazy rendering + By default, the expansion panel content will be initialized even when the panel is closed. To instead defer initialization until the panel is open, the content should be provided as an `ng-template`: + ```html