angularjs - How can I access the following json data in Angular JS? -


well here json

{ "questions" : {                  "question 1" : [                  { "q" :"question" },                  { "a" : "answer a"  },                  { "b" : "answer b" },                  { "c" : "answer c" },                  { "d" : "answer d" },                  { "answer" : "c" }                  ],                  "question 2" : [                  { "q" :"question" },                  { "a" : "answer a"  },                  { "b" : "answer b" },                  { "c" : "answer c" },                  { "d" : "answer d" },                  { "answer" : "c" }                  ] ,           "question 3":{                     "x":"qwerty",                   "y":"postdata"  }    }}

what want first display names "question 1", "question "2 etc .. links pretty easy of

<div ng-repeat="(key,val) in questions" ><a href="#" > {{key}}</a> </div>

now based on user click on links ,i have display details inside array. please suggest how . in advance .

i don't think can go , use json. first should format array of question objects array.prototype.foreach (or map):

  [     {         name: 'question 1',         body: 'foo', // here use { "q" :"question" } value         answers: [{ "answer" : "answer a", "answeroption": "a" },                   { "answer" : "answer b", "answeroption": "b" },                   { "answer" : "answer c", "answeroption": "c" },                   { "answer" : "answer d", "answeroption": "d" }],        correctanswer: "c" // here use info { "answer" : "c" }       }   ] 

and can iterate. here example


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -