@Component({
selector: 'app-filters',
template: 'Filters form..'
})
export class FiltersComponent implements OnInit {
filters: FormGroup;
persistForm: PersistNgFormPlugin;
constructor(private productsQuery: ProductsQuery) { }
ngOnInit() {
this.filters = new FormGroup({
condition: new FormGroup({
new: new FormControl(false),
used: new FormControl(false),
notSpecified: new FormControl(false)
}),
location: new FormControl()
});
this.persistForm = new PersistNgFormPlugin(this.productsQuery, 'ui.filters')
.setForm(this.filters);
}
reset() {
// reset the current state to the initial value
this.persistForm.reset();
}
ngOnDestroy() {
this.persistForm.destroy();
}
}