diff --git a/guides/creating-a-custom-form-field-control.md b/guides/creating-a-custom-form-field-control.md index 4d5f219317ab..a6d3d8f98bd0 100644 --- a/guides/creating-a-custom-form-field-control.md +++ b/guides/creating-a-custom-form-field-control.md @@ -307,22 +307,14 @@ make up our component. ```ts @Input() -get disabled() { - return this._disabled; -} -set disabled(dis) { - this._disabled = coerceBooleanProperty(dis); +get disabled(): boolean { return this._disabled; } +set disabled(value: boolean) { + this._disabled = coerceBooleanProperty(value); + this._disabled ? this.parts.disable() : this.parts.enable(); this.stateChanges.next(); } private _disabled = false; ``` -```html - - - - - -``` #### `errorState` diff --git a/src/material-examples/form-field-custom-control/form-field-custom-control-example.ts b/src/material-examples/form-field-custom-control/form-field-custom-control-example.ts index 27ba34b0af77..60ef21b5e652 100644 --- a/src/material-examples/form-field-custom-control/form-field-custom-control-example.ts +++ b/src/material-examples/form-field-custom-control/form-field-custom-control-example.ts @@ -70,6 +70,7 @@ export class MyTelInput implements MatFormFieldControl, OnDestroy { get disabled(): boolean { return this._disabled; } set disabled(value: boolean) { this._disabled = coerceBooleanProperty(value); + this._disabled ? this.parts.disable() : this.parts.enable(); this.stateChanges.next(); } private _disabled = false;