player
|-nickname
|-date
|-inventory (array)
|- object_name
|- price
|- color
Well, so i’m newbie at this subject and I dont know how to add an item into the array of item (it’s ‘Inventory’), and inventory belongs to a player, obviously. How it’s the method? don’t know if I need to use a subscribe or a observable also…
Thank you very much
Regards
UPDATED:
I did that code, but doesn’t work, what should I do?
addItem(item: Item, player: Player) {
if (item) {
player.inventory.push(item)
this.provider.editPlayer(player)
this.toast.show(`Se ha añadido el item al player ${player.inventory}`)
this.navCtrl.setRoot('HomePage')
}
};
have you made an interface for player? Yes, then please show it, because a correct interface should help with that, because it shows an error if there is something wrong, Maybe inventory should not be an array and should be itself defined as interface.
Do not hesitate to ask me for more information to resolve the problem, thank you very much, could you give me an example about how to add an item to an array of object (array of ‘Item’ object) ??¿
as you wrote or @Jacktoolsnet wrote, it seems for me that the code to push is correct syntax. So is there any error message or is checked that inventory exist or any further information or…