Skip to content

Commit

Permalink
fix: Wrong work with exists nested exeperemental sample (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis CI committed Dec 21, 2018
1 parent 90f8c3e commit 407b9de
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DynamicFormGroup } from './dynamic-form-group';
export class DynamicFormBuilder extends FormBuilder {

private createEmptyObject<TModel>(factoryModel: ClassType<TModel>, data = {}) {
const object = factoryModel ? plainToClass(factoryModel, data) : data;
const object: any = factoryModel ? plainToClass(factoryModel, data) : data;
let modifed = false;
const keys = Object.keys(object);
keys.forEach((key: any) => {
Expand Down Expand Up @@ -64,28 +64,28 @@ export class DynamicFormBuilder extends FormBuilder {
Object.keys(newControlsConfig).forEach(key => {
if (
newControlsConfig[key] &&
!Array.isArray(newControlsConfig[key]) &&
newControlsConfig[key].constructor &&
typeof newControlsConfig[key] === 'object' &&
(newControlsConfig[key].length === undefined ||
(newControlsConfig[key].length !== undefined &&
Object.keys(newControlsConfig[key].length).length === newControlsConfig[key].length))
Object.keys(newControlsConfig[key]).length === newControlsConfig[key].length))
) {
newControlsConfig[key] = this.group(newControlsConfig[key].constructor, newControlsConfig[key], extra);
newControlsConfig[key] = this.group(newControlsConfig[key].constructor, extra);
} else {
if (
Array.isArray(newControlsConfig[key]) &&
newControlsConfig[key][0].constructor &&
typeof newControlsConfig[key][0] === 'object' &&
(newControlsConfig[key][0].length === undefined ||
(newControlsConfig[key][0].length !== undefined &&
Object.keys(newControlsConfig[key][0].length).length === newControlsConfig[key][0].length))
Object.keys(newControlsConfig[key][0]).length === newControlsConfig[key][0].length))
) {
if (newControlsConfig[key][0].constructor) {
newControlsConfig[key] = super.array(
newControlsConfig[key].map(newControlsConfigItem =>
this.group(
newControlsConfigItem.constructor,
newControlsConfigItem,
extra
)
)
Expand Down

0 comments on commit 407b9de

Please sign in to comment.