Преглед на файлове

Adding updateForm to Dynaform.service

Richard Knight преди 6 години
родител
ревизия
cae172e71c
променени са 1 файла, в които са добавени 6 реда и са изтрити 0 реда
  1. 6 0
      src/app/dynaform/services/dynaform.service.ts

+ 6 - 0
src/app/dynaform/services/dynaform.service.ts

@@ -155,6 +155,12 @@ export class DynaformService {
 		}
 	}
 
+	updateForm(newModel: StringMap, form: FormGroup, meta: StringMap): void {
+		const mapping = extractFieldMappings(meta); // Memoize
+		const mappedModel = this.modelMapper.reverseMap(newModel, mapping);
+		form.patchValue(mappedModel);
+	}
+
 	buildNewModel(originalModel: StringMap, formVal: StringMap, meta: StringMap): StringMap {
 		console.log('%c *** buildNewModel *** ', this.conGreen);
 		const mapping = extractFieldMappings(meta); // Memoize