I am trying to add products to Cart by clicking STORE []. Then, I am changing label\'s color for that added list.
After that,
you are directly changing color of the rendered object because of which when object is recycled it persist that color.
you can achieve same effect by changing object property when clicked. and based on that property applying styles. like className="{{isClicked?'clickedCart':'notClickedCart'}}"
or stle.color="{{isClicked?'red':'blue'}}"
here is updated playground demo:https://play.nativescript.org/?template=play-js&id=T6sna8&v=8
Coding
.js
exports.cartColorChange = function(args) {
var lbl = args.object;
var item=lbl.bindingContext;
var index = secondArray.indexOf(item)
console.log("Clicked item with index " + index);
item.isClicked = !item.isClicked;
secondArray.setItem(index,item);
// lbl.color = "rgb(171, 0, 230)";
};
.xml
.css
Label.clickedCart{
color:rgb(171, 0, 230);
}
Label.notClickedCart{
color:gray;
}