Reputation: 381
My parent component subscribes to param changes:
this.route.queryParamMap.pipe(take(1)).subscribe(params => {
const changedQueryParams = {};
params.keys.forEach((key) => {
const values = params.getAll(key);
if (values.length > 0) {
changedQueryParams[key] = values;
}
});
this.queryParams = changedQueryParams;
populating an object:
queryParams = {};
I pass it to my child component which has a FormGroup
<child-component
[queryParams]="queryParams"
></child-component
the child component's variable:
@Input() queryParams= {};
The ngOnChanges:
ngOnChanges(changes: any): void {
if(changes.queryParams && changes.isFirsChange){
this.filterFormGroup.patchValue(changes.queryParams, {emitEvent:true})
}
}
I've tried defining the object in the parent component based off other answers I've seen on here:
this.queryParams = {...changedQueryParams}
I did some console.logs
but nothing is printing out.
Why isn't my formgroup updating?
Upvotes: 1
Views: 88