Ć
Size: a a a
Ć
Ć
Ć
AddToFavorites(info) {
if (info.id in this.favorites) {
delete this.favorites[info.id];
} else {
this.favorites[info.id] = info;
}
this.storage.set('_favs', this.favorites).then((items: any) => {
this.favorites = items;
}).catch(err => {
console.log(err);
});
}
Ć
Ć
Ć
ГЩ
let AddToFavorites = (info, favorites) => {
let currentIndex;
if(favorites.some( (elem, index) => {
if(elem.id === info.id) {
currentIndex = index;
return true;
}
})) {
favorites.splice(currentIndex, 1);
} else {
favorites.push(info);
}
return favorites
}
Ć
AddToFavorites(info) {
if (info.id in this.favorites) {
delete this.favorites[info.id];
} else {
this.favorites[info.id] = info;
}
this.storage.set('_favs', this.favorites).then((items: any) => {
this.favorites = items;
}).catch(err => {
console.log(err);
});
}
ГЩ
Ć
Ć
Ć
ГЩ
ГЩ
Ć
Ć
ГЩ
ГЩ
keys = Object.keys(favorites);
ngFor( let key in keys) {
favorites[key]...
}