瀏覽代碼

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