### File

`src/lib/mixins/extract-control.mixin.ts`

### Index

###### Properties
Protected Optional control Protected Optional matFormField Protected ngControl
###### Methods
Protected extractControl

### Properties

Protected Optional control
Type : `RxapFormControl`
Defined in src/lib/mixins/extract-control.mixin.ts:14

Protected Optional matFormField
Type : `MatFormField | null`
Defined in src/lib/mixins/extract-control.mixin.ts:12

Protected ngControl
Type : `NgControl | AbstractControlDirective | null`
Defined in src/lib/mixins/extract-control.mixin.ts:10

### Methods

Protected extractControl
`extractControl(ngControl: NgControl | AbstractControlDirective | null)`
Defined in src/lib/mixins/extract-control.mixin.ts:16
Parameters :
Name | Type | Optional | Default value
ngControl | `NgControl | AbstractControlDirective | null` | No | `this.ngControl ?? this.matFormField?._control?.ngControl ?? null`
Returns : `RxapFormControl`

    import {
      AbstractControlDirective,
      NgControl,
    } from '@angular/forms';
    import { MatFormField } from '@angular/material/form-field';
    import { RxapFormControl } from '@rxap/forms';

    export class ExtractControlMixin {

      protected ngControl!: NgControl | AbstractControlDirective | null;

      protected matFormField?: MatFormField | null;

      protected control?: RxapFormControl;

      protected extractControl(ngControl: NgControl | AbstractControlDirective | null = this.ngControl ??
      this.matFormField?._control?.ngControl ??
      null): RxapFormControl {

        if (!ngControl) {
          throw new Error('The ngControl is not defined!');
        }

        this.ngControl = ngControl;

        const control = this.ngControl.control;

        if (!(control instanceof RxapFormControl)) {
          throw new Error('Control is not a RxapFormControl!');
        }

        return this.control = control;
      }

    }

# results matching ""

# No results matching ""