Skip to content

Commit 9d1d6db

Browse files
authored
fix(form): connect formGroup input not mapped to connect base (#94)
fixes #85
1 parent fcea502 commit 9d1d6db

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/form/src/connect/connect-base.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class ConnectBase implements OnDestroy, AfterContentInit {
4646
}
4747
@Input() connect?: () => (string | number) | (string | number)[];
4848
protected store?: FormStore;
49-
protected form: any;
49+
protected formGroup: any;
5050
private stateSubscription?: Unsubscribe;
5151

5252
private formSubscription?: Subscription;
@@ -70,7 +70,7 @@ export class ConnectBase implements OnDestroy, AfterContentInit {
7070
}
7171

7272
Promise.resolve().then(() => {
73-
this.formSubscription = (this.form.valueChanges as any)
73+
this.formSubscription = (this.formGroup.valueChanges as any)
7474
.pipe(debounceTime(0))
7575
.subscribe((values: any) => this.publish(values));
7676
});
@@ -106,13 +106,15 @@ export class ConnectBase implements OnDestroy, AfterContentInit {
106106

107107
return pairs.filter(p => {
108108
const parent = (p.control as any)._parent;
109-
return parent === this.form.control || parent === this.form;
109+
return parent === this.formGroup.control || parent === this.formGroup;
110110
});
111111
}
112112

113113
private resetState() {
114114
const formElement =
115-
this.form.control === undefined ? this.form : this.form.control;
115+
this.formGroup.control === undefined
116+
? this.formGroup
117+
: this.formGroup.control;
116118

117119
const children = this.descendants([], formElement);
118120

@@ -129,7 +131,7 @@ export class ConnectBase implements OnDestroy, AfterContentInit {
129131

130132
private publish(value: any) {
131133
if (this.store) {
132-
this.store.valueChanged(this.path, this.form, value);
134+
this.store.valueChanged(this.path, this.formGroup, value);
133135
}
134136
}
135137

packages/form/src/connect/connect.directive.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ConnectBase } from './connect-base';
88
// For template forms (with implicit NgForm)
99
@Directive({ selector: 'form[connect]:not([formGroup])' })
1010
export class ConnectDirective extends ConnectBase {
11-
constructor(protected store: FormStore, protected form: NgForm) {
11+
constructor(protected store: FormStore, protected formGroup: NgForm) {
1212
super();
1313
}
1414
}

0 commit comments

Comments
 (0)