|
@@ -1,4 +1,4 @@
|
|
|
-import { Component, Input, TemplateRef, Optional, OnInit } from '@angular/core';
|
|
|
+import { Component, Input, TemplateRef, Optional, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
|
|
import { FormGroup, FormGroupName, AbstractControl, ControlContainer } from '@angular/forms';
|
|
|
|
|
|
export interface DynarowContext {
|
|
@@ -9,7 +9,8 @@ export interface DynarowContext {
|
|
|
@Component({
|
|
|
selector: 'app-dynaform',
|
|
|
templateUrl: './dynaform.component.html',
|
|
|
- styleUrls: ['./dynaform.component.scss']
|
|
|
+ styleUrls: ['./dynaform.component.scss'],
|
|
|
+ changeDetection: ChangeDetectionStrategy.OnPush
|
|
|
})
|
|
|
export class DynaformComponent implements OnInit {
|
|
|
|
|
@@ -44,7 +45,7 @@ export class DynaformComponent implements OnInit {
|
|
|
|
|
|
@Input()
|
|
|
set meta(data) {
|
|
|
- this.formMetaData = data;
|
|
|
+ this.formMetaData = this.formMetaData || data;
|
|
|
}
|
|
|
|
|
|
@Input()
|
|
@@ -98,7 +99,7 @@ export class DynaformComponent implements OnInit {
|
|
|
let fg = this.formGroup;
|
|
|
while (fg.parent) {
|
|
|
|
|
|
- const fgIdentity = Object.entries(fg.parent.controls).filter(([key, candidate]) => candidate === fg).pop();
|
|
|
+ const fgIdentity = Object.entries(fg.parent.controls).find(([key, candidate]) => candidate === fg);
|
|
|
path.push(fgIdentity[0]);
|
|
|
fg = <FormGroup>fg.parent;
|
|
|
}
|
|
@@ -107,6 +108,7 @@ export class DynaformComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
getTemplateContext(controlName: string): DynarowContext {
|
|
|
+
|
|
|
return {
|
|
|
control: this.formGroup.get(controlName),
|
|
|
meta: this.formMetaData[controlName]
|