### File

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

### Index

###### Methods

- Protected extractControlFromParent

### Methods

Protected extractControlFromParent
`extractControlFromParent(parent: ControlContainer, controlPath: string)`
Defined in src/lib/mixins/extract-control-from-parent.mixin.ts:12

Parameters :

Name | Type | Optional
parent | `ControlContainer` | No
controlPath | `string` | No

Returns : `AbstractControl`

    import { ControlContainer } from '@angular/forms';
    import {
      AbstractControl,
      RxapFormArray,
      RxapFormControl,
      RxapFormGroup,
    } from '@rxap/forms';
    import { RxapFormSystemError } from '../error';

    export class ExtractControlFromParentMixin {

      protected extractControlFromParent(parent: ControlContainer, controlPath: string): AbstractControl {
        if (!controlPath) {
          throw new RxapFormSystemError('The control path is empty', '');
        }

        if (!parent.control) {
          throw new RxapFormSystemError('The control property of ControlContainer is not defined', '');
        }

        const control = parent.control.get(controlPath);

        if (!control) {
          throw new RxapFormSystemError('Could not find the control instance', '');
        }

        if (!(control instanceof RxapFormControl) &&
          !(control instanceof RxapFormGroup) &&
          !(control instanceof RxapFormArray)) {
          throw new RxapFormSystemError('The extracted control is not a RxapFormControl', '');
        }

        return control;
      }

    }

# results matching ""

# No results matching ""