I want to make a simple selection of items - where people could select from my Array(a) and add to Array(b). Also they can remove from Array(b) and they can select all Array(a) to Array(b) - then deselect the unwanted. Simply :
1.Array(a).item.clicked --> Array(b).item added
2.Array(a).item.clicked 2nd time --> Array(b).item.deleted
3.Array(a).selectAll = Array(b) { if(selected.all) { Array(a).item.clicked --> Array(b).item.removed } }
My start (example with explanation) :
oneFunctionForAll(){
if(clicked-first-tiem) {
addCompare(item)
}
}
if(clicked-second-time){
removeCompore(item, i)
}
if(selected-all-and-clicked) {
removeCompore(item, i)
}
if(selected-all-and-clicked 2nd-time) {
addCompare(item)
}
}
addCompare(item) {
this.compare.push(item)
console.log('Prideda',this.compare)
}
removeCompore(item, i) {
const index = this.compare.indexOf(i)
if (index !== -1) {
this.compare.splice(index, 1);
}
console.log('triname',this.compare)
}
HTML :
<ion-card *ngFor="let item of jsonObj | slice:0:4; let i = index"
class="relative" (click)="oneFunctionForAll(item,i);"> </ion-card>
If you have some ideas or done it before, I would like to see how you implemented this. I am struggling now for some reason. Please write if need more information - I will provide it.