From b46bb5ae706eea8eceb8a8bbd999b56df31cc872 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 30 Aug 2017 17:55:50 +0200 Subject: [PATCH] fix: reactive forms not updating on changes in store Signed-off-by: Peter Leibiger --- source/connect/connect-base.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/connect/connect-base.ts b/source/connect/connect-base.ts index c4c1ecc..ae413a1 100644 --- a/source/connect/connect-base.ts +++ b/source/connect/connect-base.ts @@ -97,7 +97,10 @@ export class ConnectBase { throw new Error(`Unknown type of form element: ${formElement.constructor.name}`); } - return pairs.filter(p => (p.control)._parent === this.form.control); + return pairs.filter(p => { + const parent = (p.control as any)._parent; + return parent === this.form.control || parent === this.form; + }); } private resetState() { @@ -114,12 +117,10 @@ export class ConnectBase { children.forEach(c => { const { path, control } = c; - const value = State.get(this.getState(), this.path.concat(c.path)); + const value = State.get(this.getState(), this.path.concat(path)); if (control.value !== value) { - const phonyControl = { path: path }; - - this.form.updateModel(phonyControl, value); + control.setValue(value); } }); }