I have a button which creates an array with an object like
[{field: field1, operator: operator1, value: 10}]
when I click on the button again it will again creates a new array like
[{field: field2, operator: operator2, value: 20}]
When I tried to push these into new array, it is becoming nested
[Array(1), Array(1)]
But I want the new array to look like
[{field: field1, operator: operator1, value: 10}, {field: field2, operator: operator2, value: 20}]
My code
public filterChange(state): void {
this.filters.push( state.filters );
console.log(this.filters);
}
On each click of the button 'filterChange' will call and 'state' will give the filters array generated with new filter values. Please suggest. Thanks.