Having 2 lists presents a challenge.
An Angular service is utilized with a splice
-based method to remove items from the first list (named "items
") according to their index through a ng-click
action.
service.removeItem = function (itemIndex) {
items.splice(itemIndex, 1);
};
The goal is to transfer the removed item to the second list (called "bought
") using the same index passed to slice
.
Initially, combining this functionality into the same function (removeItem
) was considered:
service.removeItem = function (itemIndex) {
bought.push(itemIndex);
items.splice(itemIndex, 1);
};
Unfortunately, this approach did not yield positive results. Several attempts were made such as bought.push(items.itemIndex)
, but without success.