Skip to content

Commit 43a87a4

Browse files
authored
docs: convert Stepper/Tabs/Timepicker example to signals (#33536)
1 parent ce6875e commit 43a87a4

21 files changed

Lines changed: 84 additions & 74 deletions

‎src/components-examples/material/stepper/stepper-editable/stepper-editable-example.html‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<button matButton="elevated" (click)="isEditable = !isEditable">
2-
{{!isEditable ? 'Enable edit mode' : 'Disable edit mode'}}
1+
<button matButton="elevated" (click)="isEditable.set(!isEditable())">
2+
{{!isEditable() ? 'Enable edit mode' : 'Disable edit mode'}}
33
</button>
44

55
<mat-stepper linear #stepper>
66
<!-- #docregion editable -->
7-
<mat-step [stepControl]="firstFormGroup" [editable]="isEditable">
7+
<mat-step [stepControl]="firstFormGroup" [editable]="isEditable()">
88
<!-- #enddocregion editable -->
99
<form [formGroup]="firstFormGroup">
1010
<!-- #docregion step-label -->
@@ -19,7 +19,7 @@
1919
</div>
2020
</form>
2121
</mat-step>
22-
<mat-step [stepControl]="secondFormGroup" [editable]="isEditable">
22+
<mat-step [stepControl]="secondFormGroup" [editable]="isEditable()">
2323
<form [formGroup]="secondFormGroup">
2424
<ng-template matStepLabel>Fill out your address</ng-template>
2525
<mat-form-field>

‎src/components-examples/material/stepper/stepper-editable/stepper-editable-example.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, inject} from '@angular/core';
1+
import {Component, inject, signal} from '@angular/core';
22
import {FormBuilder, Validators, FormsModule, ReactiveFormsModule} from '@angular/forms';
33
import {MatInputModule} from '@angular/material/input';
44
import {MatFormFieldModule} from '@angular/material/form-field';
@@ -30,5 +30,6 @@ export class StepperEditableExample {
3030
secondFormGroup = this._formBuilder.group({
3131
secondCtrl: ['', Validators.required],
3232
});
33-
isEditable = false;
33+
34+
isEditable = signal(false);
3435
}

‎src/components-examples/material/stepper/stepper-intl/stepper-intl-example.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Service, inject} from '@angular/core';
1+
import {Component, Service, inject, signal} from '@angular/core';
22
import {FormBuilder, Validators, FormsModule, ReactiveFormsModule} from '@angular/forms';
33
import {MatStepperIntl, MatStepperModule} from '@angular/material/stepper';
44
import {MatButtonModule} from '@angular/material/button';
@@ -34,7 +34,7 @@ export class StepperIntlExample {
3434
private _formBuilder = inject(FormBuilder);
3535
private _matStepperIntl = inject(MatStepperIntl);
3636

37-
optionalLabelText = '';
37+
optionalLabelText = signal('');
3838
optionalLabelTextChoices: string[] = ['Option 1', 'Option 2', 'Option 3'];
3939
firstFormGroup = this._formBuilder.group({
4040
firstCtrl: ['', Validators.required],
@@ -44,7 +44,7 @@ export class StepperIntlExample {
4444
});
4545

4646
updateOptionalLabel() {
47-
this._matStepperIntl.optionalLabel = this.optionalLabelText;
47+
this._matStepperIntl.optionalLabel = this.optionalLabelText();
4848
// Required for the optional label text to be updated
4949
// Notifies the MatStepperIntl service that a change has been made
5050
this._matStepperIntl.changes.next();

‎src/components-examples/material/stepper/stepper-optional/stepper-optional-example.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<button matButton="elevated" (click)="isOptional = !isOptional">
2-
{{!isOptional ? 'Enable optional steps' : 'Disable optional steps'}}
1+
<button matButton="elevated" (click)="isOptional.set(!isOptional())">
2+
{{!isOptional() ? 'Enable optional steps' : 'Disable optional steps'}}
33
</button>
44

55
<mat-stepper linear #stepper>
@@ -16,7 +16,7 @@
1616
</form>
1717
</mat-step>
1818
<!-- #docregion optional -->
19-
<mat-step [stepControl]="secondFormGroup" [optional]="isOptional">
19+
<mat-step [stepControl]="secondFormGroup" [optional]="isOptional()">
2020
<!-- #enddocregion optional -->
2121
<form [formGroup]="secondFormGroup">
2222
<ng-template matStepLabel>Fill out your address</ng-template>

‎src/components-examples/material/stepper/stepper-optional/stepper-optional-example.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, inject} from '@angular/core';
1+
import {Component, inject, signal} from '@angular/core';
22
import {FormBuilder, Validators, FormsModule, ReactiveFormsModule} from '@angular/forms';
33
import {MatInputModule} from '@angular/material/input';
44
import {MatFormFieldModule} from '@angular/material/form-field';
@@ -30,5 +30,6 @@ export class StepperOptionalExample {
3030
secondFormGroup = this._formBuilder.group({
3131
secondCtrl: '',
3232
});
33-
isOptional = false;
33+
34+
isOptional = signal(false);
3435
}

‎src/components-examples/material/stepper/stepper-overview/stepper-overview-example.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<button matButton="elevated" (click)="isLinear = !isLinear" id="toggle-linear">
2-
{{!isLinear ? 'Enable linear mode' : 'Disable linear mode'}}
1+
<button matButton="elevated" (click)="isLinear.set(!isLinear())" id="toggle-linear">
2+
{{!isLinear() ? 'Enable linear mode' : 'Disable linear mode'}}
33
</button>
4-
<mat-stepper [linear]="isLinear" #stepper>
4+
<mat-stepper [linear]="isLinear()" #stepper>
55
<mat-step [stepControl]="firstFormGroup">
66
<form [formGroup]="firstFormGroup">
77
<ng-template matStepLabel>Fill out your name</ng-template>

‎src/components-examples/material/stepper/stepper-overview/stepper-overview-example.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, inject} from '@angular/core';
1+
import {Component, inject, signal} from '@angular/core';
22
import {FormBuilder, Validators, FormsModule, ReactiveFormsModule} from '@angular/forms';
33
import {MatInputModule} from '@angular/material/input';
44
import {MatFormFieldModule} from '@angular/material/form-field';
@@ -30,5 +30,6 @@ export class StepperOverviewExample {
3030
secondFormGroup = this._formBuilder.group({
3131
secondCtrl: ['', Validators.required],
3232
});
33-
isLinear = false;
33+
34+
isLinear = signal(false);
3435
}

‎src/components-examples/material/stepper/stepper-vertical/stepper-vertical-example.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<button matButton="elevated" (click)="isLinear = !isLinear" id="toggle-linear">
2-
{{!isLinear ? 'Enable linear mode' : 'Disable linear mode'}}
1+
<button matButton="elevated" (click)="isLinear.set(!isLinear())" id="toggle-linear">
2+
{{!isLinear() ? 'Enable linear mode' : 'Disable linear mode'}}
33
</button>
4-
<mat-stepper orientation="vertical" [linear]="isLinear" #stepper>
4+
<mat-stepper orientation="vertical" [linear]="isLinear()" #stepper>
55
<mat-step [stepControl]="firstFormGroup">
66
<form [formGroup]="firstFormGroup">
77
<ng-template matStepLabel>Fill out your name</ng-template>

‎src/components-examples/material/stepper/stepper-vertical/stepper-vertical-example.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, inject} from '@angular/core';
1+
import {Component, inject, signal} from '@angular/core';
22
import {FormBuilder, Validators, FormsModule, ReactiveFormsModule} from '@angular/forms';
33
import {MatInputModule} from '@angular/material/input';
44
import {MatFormFieldModule} from '@angular/material/form-field';
@@ -30,5 +30,6 @@ export class StepperVerticalExample {
3030
secondFormGroup = this._formBuilder.group({
3131
secondCtrl: ['', Validators.required],
3232
});
33-
isLinear = false;
33+
34+
isLinear = signal(false);
3435
}

‎src/components-examples/material/tabs/tab-group-async/tab-group-async-example.ts‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {Component} from '@angular/core';
2-
import {Observable, Observer} from 'rxjs';
2+
import {Observable, of} from 'rxjs';
33
import {MatTabsModule} from '@angular/material/tabs';
44
import {AsyncPipe} from '@angular/common';
5+
import {delay} from 'rxjs/operators';
56

67
export interface ExampleTab {
78
label: string;
@@ -20,14 +21,10 @@ export class TabGroupAsyncExample {
2021
asyncTabs: Observable<ExampleTab[]>;
2122

2223
constructor() {
23-
this.asyncTabs = new Observable((observer: Observer<ExampleTab[]>) => {
24-
setTimeout(() => {
25-
observer.next([
26-
{label: 'First', content: 'Content 1'},
27-
{label: 'Second', content: 'Content 2'},
28-
{label: 'Third', content: 'Content 3'},
29-
]);
30-
}, 1000);
31-
});
24+
this.asyncTabs = of([
25+
{label: 'First', content: 'Content 1'},
26+
{label: 'Second', content: 'Content 2'},
27+
{label: 'Third', content: 'Content 3'},
28+
]).pipe(delay(1000));
3229
}
3330
}

0 commit comments

Comments
 (0)