1234567891011121314151617181920212223242526272829 |
- import { Input, OnInit } from '@angular/core';
- import { FormGroup, FormArray } from '@angular/forms';
- export abstract class GroupInputComponent implements OnInit {
- @Input()
- control: FormGroup | FormArray;
- @Input()
- meta;
- formGroup: FormGroup;
- childMetaArray: Array<StringMap>;
- controlNames: Array<string>;
- exposeMetaInTemplate: string[] = [];
- ngOnInit() {
- // Move meta variables up a level, for direct access in templates
- this.exposeMetaInTemplate.map(p => this[p] = this.meta[p] !== undefined ? this.meta[p] : this[p]);
- // Get the FormGroup, and information about the controls inside it
- this.formGroup = this.control as FormGroup;
- this.childMetaArray = Object.values(this.meta.meta); // Metadata array of all controls in group
- this.controlNames = Object.keys(this.formGroup.controls);
- }
- }
|