1 回答
TA贡献1891条经验 获得超3个赞
改用怎么样OnChanges?检查您的更改状态/值@Input() filters
import { OnChanges, SimpleChanges } from '@angular/core';
@Component({...})
export class ChildComponent implements OnInit, OnChanges {
...
@Input() filters: MessageFilter;
ngOnChanges({ filters }: SimpleChanges) {
console.log(filters); // if you want to check any states/activities
if (filters && filters.currentValue && filters.currentValue.kind)
this.form.patchValue({ kind: this.filters.kind });
}
ngOnInit() {
this.form.valueChanges.pipe(
untilDestroyed(this),
distinctUntilChanged(),
).subscribe(values => this.updateFilters.emit(values.kind));
}
}
添加回答
举报