I have problem with params. I am using filter method to get every key, value from different componet (form).
The problem is with result in the end.
filterTable(filters: { data: any; isReset: boolean }) {
let params = new HttpParams();
for (const key in filters.data) {
if (Object.prototype.hasOwnProperty.call(filters.data, key)) {
const jsonData = JSON.stringify({ drilldown: { [key]: { op: 'EQ', value: filters.data[key] } } });
params = params.append('filter', jsonData);
}
}
Is there way how could i not add in query params key with null value?
If you want to remove the entire filter, just add this condition to your if : filters.data[key]
for (const key in filters.data) {
if (Object.prototype.hasOwnProperty.call(filters.data, key) && filters.data[key]) {
const jsonData = JSON.stringify({ drilldown: { [key]: { op: 'EQ', value: filters.data[key] } } });
params = params.append('filter', jsonData);
}
}