-- None --
Option
diff --git a/src/components-examples/material/form-field/form-field-label/form-field-label-example.ts b/src/components-examples/material/form-field/form-field-label/form-field-label-example.ts
index 7cdc7a52450b..a11f34d34301 100644
--- a/src/components-examples/material/form-field/form-field-label/form-field-label-example.ts
+++ b/src/components-examples/material/form-field/form-field-label/form-field-label-example.ts
@@ -1,11 +1,13 @@
-import {Component} from '@angular/core';
+import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
+import {toSignal} from '@angular/core/rxjs-interop';
import {FormBuilder, FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
+import {MatCheckboxModule} from '@angular/material/checkbox';
import {FloatLabelType, MatFormFieldModule} from '@angular/material/form-field';
import {MatIconModule} from '@angular/material/icon';
-import {MatSelectModule} from '@angular/material/select';
import {MatInputModule} from '@angular/material/input';
import {MatRadioModule} from '@angular/material/radio';
-import {MatCheckboxModule} from '@angular/material/checkbox';
+import {MatSelectModule} from '@angular/material/select';
+import {map} from 'rxjs/operators';
/** @title Form field with label */
@Component({
@@ -23,18 +25,18 @@ import {MatCheckboxModule} from '@angular/material/checkbox';
MatSelectModule,
MatIconModule,
],
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FormFieldLabelExample {
- hideRequiredControl = new FormControl(false);
- floatLabelControl = new FormControl('auto' as FloatLabelType);
- options = this._formBuilder.group({
+ readonly hideRequiredControl = new FormControl(false);
+ readonly floatLabelControl = new FormControl('auto' as FloatLabelType);
+ readonly options = inject(FormBuilder).group({
hideRequired: this.hideRequiredControl,
floatLabel: this.floatLabelControl,
});
-
- constructor(private _formBuilder: FormBuilder) {}
-
- getFloatLabelValue(): FloatLabelType {
- return this.floatLabelControl.value || 'auto';
- }
+ protected readonly hideRequired = toSignal(this.hideRequiredControl.valueChanges);
+ protected readonly floatLabel = toSignal(
+ this.floatLabelControl.valueChanges.pipe(map(v => v || 'auto')),
+ {initialValue: 'auto'},
+ );
}
diff --git a/src/components-examples/material/form-field/form-field-overview/form-field-overview-example.ts b/src/components-examples/material/form-field/form-field-overview/form-field-overview-example.ts
index c5a820960ab9..c1d4ffe7a63a 100644
--- a/src/components-examples/material/form-field/form-field-overview/form-field-overview-example.ts
+++ b/src/components-examples/material/form-field/form-field-overview/form-field-overview-example.ts
@@ -1,4 +1,4 @@
-import {Component} from '@angular/core';
+import {ChangeDetectionStrategy, Component} from '@angular/core';
import {MatSelectModule} from '@angular/material/select';
import {MatInputModule} from '@angular/material/input';
import {MatFormFieldModule} from '@angular/material/form-field';
@@ -10,5 +10,6 @@ import {MatFormFieldModule} from '@angular/material/form-field';
styleUrl: 'form-field-overview-example.css',
standalone: true,
imports: [MatFormFieldModule, MatInputModule, MatSelectModule],
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FormFieldOverviewExample {}
diff --git a/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.html b/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.html
index dd514eb6ba49..3bf388ecc9b2 100644
--- a/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.html
+++ b/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.html
@@ -1,15 +1,21 @@
Enter your password
-
-
Amount
-
+
$
.00
diff --git a/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.ts b/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.ts
index ca65f80ffd12..98f37a5ad0a9 100644
--- a/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.ts
+++ b/src/components-examples/material/form-field/form-field-prefix-suffix/form-field-prefix-suffix-example.ts
@@ -1,8 +1,8 @@
-import {Component} from '@angular/core';
-import {MatIconModule} from '@angular/material/icon';
+import {ChangeDetectionStrategy, Component, signal} from '@angular/core';
import {MatButtonModule} from '@angular/material/button';
-import {MatInputModule} from '@angular/material/input';
import {MatFormFieldModule} from '@angular/material/form-field';
+import {MatIconModule} from '@angular/material/icon';
+import {MatInputModule} from '@angular/material/input';
/** @title Form field with prefix & suffix */
@Component({
@@ -11,11 +11,12 @@ import {MatFormFieldModule} from '@angular/material/form-field';
styleUrl: 'form-field-prefix-suffix-example.css',
standalone: true,
imports: [MatFormFieldModule, MatInputModule, MatButtonModule, MatIconModule],
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FormFieldPrefixSuffixExample {
- hide = true;
+ hide = signal(true);
clickEvent(event: MouseEvent) {
- this.hide = !this.hide;
+ this.hide.set(!this.hide);
event.stopPropagation();
}
}
diff --git a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.css b/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.css
deleted file mode 100644
index d98172fcc0a3..000000000000
--- a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.example-container mat-form-field + mat-form-field {
- margin-left: 8px;
-}
diff --git a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.html b/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.html
deleted file mode 100644
index 6b455564f846..000000000000
--- a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
- Color
-
- Primary
- Accent
- Warn
-
-
diff --git a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.ts b/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.ts
deleted file mode 100644
index 5f21cc74fef9..000000000000
--- a/src/components-examples/material/form-field/form-field-theming/form-field-theming-example.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import {Component} from '@angular/core';
-import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
-import {ThemePalette} from '@angular/material/core';
-import {MatSelectModule} from '@angular/material/select';
-import {MatFormFieldModule} from '@angular/material/form-field';
-
-/** @title Form field theming */
-@Component({
- selector: 'form-field-theming-example',
- templateUrl: 'form-field-theming-example.html',
- styleUrl: 'form-field-theming-example.css',
- standalone: true,
- imports: [MatFormFieldModule, MatSelectModule, FormsModule, ReactiveFormsModule],
-})
-export class FormFieldThemingExample {
- colorControl = new FormControl('primary' as ThemePalette);
-}
diff --git a/src/components-examples/material/form-field/index.ts b/src/components-examples/material/form-field/index.ts
index 4e22bcbb0597..99b315986fb7 100644
--- a/src/components-examples/material/form-field/index.ts
+++ b/src/components-examples/material/form-field/index.ts
@@ -4,9 +4,8 @@ export {
MyTelInput,
} from './form-field-custom-control/form-field-custom-control-example';
export {FormFieldErrorExample} from './form-field-error/form-field-error-example';
+export {FormFieldHarnessExample} from './form-field-harness/form-field-harness-example';
export {FormFieldHintExample} from './form-field-hint/form-field-hint-example';
export {FormFieldLabelExample} from './form-field-label/form-field-label-example';
export {FormFieldOverviewExample} from './form-field-overview/form-field-overview-example';
export {FormFieldPrefixSuffixExample} from './form-field-prefix-suffix/form-field-prefix-suffix-example';
-export {FormFieldThemingExample} from './form-field-theming/form-field-theming-example';
-export {FormFieldHarnessExample} from './form-field-harness/form-field-harness-example';
diff --git a/src/material/form-field/form-field.md b/src/material/form-field/form-field.md
index a393f128eb24..83d0b2b2f45e 100644
--- a/src/material/form-field/form-field.md
+++ b/src/material/form-field/form-field.md
@@ -7,14 +7,16 @@ In this document, "form field" refers to the wrapper component `
(e.g. the input, textarea, select, etc.)
The following Angular Material components are designed to work inside a ``:
-* [`` & `