There are 4 multiselect dropdown and on click event I save the data array of object in same component now I have to send this data to show it in other component.
For this I am using service. but each time, I send data it will over write the old, I am looking for solution to add the data in new array.
component
query = [
{
a: [],
b: [],
c: [],
d: []
}
];
I need to add new data into query array. can we do with Behaviorsubject
.
can anybody help me with this.
Try something like this:
addValue(v) {
const curr = this.yourBehaviorSubject.value;
this.yourBehaviorSubject.next({ a: [...curr.a, v.a], b: [...curr.b, v.b], c: [...curr.c, v.c], d: [...curr.d, v.d]});
}