I have a list, when I click on an item I would like to change the color of this item.
I dit this :
html
[ngStyle]="{'color': item.isClicked ? 'grey': ''}"
ts
itemSelected(item) {
if (item.isClicked) {
item.isClicked = true;
} else {
item.isClicked = true;
}
this.router.navigate(['/details', { data: JSON.stringify(item) }]);
}
it works but when I refresh the page it doesn't work. how do I persist ?
thanks for your help !
You can save the item in local storage before you leave the page. And restore the item from the local storage when the component is initiated: