2015-05-25 90 views
2

要訪問列表中標記的信息,我該怎麼做?我可以使用點符號嗎? Javascript在後端被使用,JavaScript被用於前端。顯示json字符串到html div

HTML:

<div>{{ GameData }}</div> 

JAVASCRIPT:

{ 
    "player_stat_summary": [ 
     { 
      "id": 1, 
      "stats": { 
       "id": 1, 
       "average_node_capture_assist": 0, 
       "max_node_neutralize_assist": 0, 
       "total_minion_kills": 0, 
       "max_champions_killed": 0, 
       "total_champion_kills": 0, 
       "average_champions_killed": 0, 
       "average_num_deaths": 0, 
       "max_node_capture": 0, 
       "max_objective_player_score": 0, 
       "total_neutral_minions_killed": 0, 
       "max_assists": 0, 
       "average_combat_player_score": 0, 
       "max_node_capture_assist": 0, 
       "average_objective_player_score": 0, 
       "max_team_objective": 0, 
       "total_assists": 0, 
       "average_node_capture": 0, 
       "average_total_player_score": 0, 
       "average_team_objective": 0, 
       "average_node_neutralize": 0, 
       "max_node_neutralize": 0, 
       "average_node_neutralize_assist": 0, 
       "average_assists": 0, 
       "max_total_player_score": 0, 
       "max_combat_player_score": 0, 
       "total_turrets_killed": 0, 
       "total_node_neutralize": 0, 
       "total_node_capture": 0 
      }, 
      "player_stat_summary_type": "Coop", 
      "wins": 100, 
      "losses": 0 
     } 
    ], 
    "time_stamp": "2015-05-22T15:54:43.069814Z", 
    "summoner_id": 0 
} 
+0

你是什麼意思的Javascript用在後端?並且您在html div標記(雙花括號)中使用的符號來自於angularjs符號。 – Malik

+0

你的意思是noje.js + angular.js? 你到底在問什麼? –

+0

如果我理解這個問題: 你可以使用像這樣的點符號... 「GameData.player_stat_summary.id」in JavaScript –

回答

0

你可以使用點符號以及字符串符號。例如,在給定的數據,你可以訪問數據的第一對象

GameData.player_stat_summary[0] 

OR

GameData["player_stat_summary"][0] 

您可以按 「player_stat_summary」 的任何屬性:

GameData.player_stat_summary[0].id 

OR

GameData["player_stat_summary"][0]["id"] 

Sim非常多的層次可以被訪問。