Although I have little experience with angularJS, I am struggling to find a clear explanation on how to bind a dictionary with an html tag so that any changes made in the dictionary reflect in the number displayed within the <p>
tag. For instance, if I have multiple dictionaries stored within an array (one for each player)
var players = [{bambu:0, clouds:0, fruits:0}, {bambu:0, clouds:0, fruits:0} , {bambu:0, clouds:0, fruits:0}]
I specifically want to showcase the number associated with "bambu" in a <p>
tag
<p id="player_0_bambu" class="number_of_cards"> </p>
My goal is to update this number dynamically similar to what angular does.
I attempted to achieve this by creating a loop:
while (true){
for (var r=0; r< num_players;r++){
for (var c=0; c< colores.length;c++){
$("#player_"+r+"_"+colores[c]).html(players[r][colores[c]])
}
}
}
However, using a while true loop ends up crashing javascript. As a result, I turned towards angular for assistance but I am finding it challenging to grasp.
Your guidance and support are greatly appreciated!