I am managing two sets of lists where strings will be transferred between them.
One set contains a list of strings for searching purposes. The other set contains the same list of strings but is not used as a filter.
The second set functions in a similar manner, holding different strings.
Strings are moved between the two sets, ensuring that no string appears in both sets simultaneously.
The "deselectedListToBeMoved" stores the strings that need to be transferred from one set to another.
selectCustomer() {
for (let deselect of this.deselectedListToBeMoved) {
this.deselectedList = this.deselectedList.filter(
(customer) => customer !== deselect
);
this.originalDeselect = this.originalDeselect.filter(
(customer) => customer !== deselect
);
this.selectedList.push(deselect);
this.originalSelect.push(deselect);
}
this.selectedList.sort((a, b) => a.localeCompare(b));
this.deselectedListToBeMoved = [];
}
*HTML*
<div id="customer_{{cus}}" class="individual-customers" *ngFor="let cus of selectedList">{{cus}}</div>
An issue arises when calling this function, causing a string to be added to 'selectedList' twice at times, displaying it twice on the frontend.
If I remove the line: "this.originalSelect.push(deselect);", the string is only added to 'selectedList' once.