While going through code left behind by a previous team member, I find myself navigating the transition to Angular solo, without anyone around to brainstorm with. This brings me to my question for the community.
I am working with JSON data that contains two nodes requiring iteration. The JSON structure is as follows:
{
"questions": [
{
"text": "Do you plan to attend the session on 6/3 at 12?",
"choices": [
{
"name": "Answer_9LUL3A",
"display": "Yes",
"value": "Yes"
},
{
"name": "Answer_9LUL3A",
"display": "No",
"value": "No"
}
]
},
{
"text": "When you get the meeting/appointment invite accept it with the Notes client (as opposed to the iDevice)",
"choices": [
{
"name": "Answer_9NFPMZ",
"display": "September 1, 2014 12:00 PM - 01:00 PM",
"value": "09/01/2014~12:00:00 PM~01:00:00 PM"
},
{
"name": "Answer_9NFPMZ",
"display": "September 1, 2014 01:00 PM - 02:00 PM",
"value": "09/01/2014~01:00:00 PM~02:00:00 PM"
},
{
"name": "Answer_9NFPMZ",
"display": "September 1, 2014 02:00 PM - 03:00 PM",
"value": "09/01/2014~02:00:00 PM~03:00:00 PM"
},
{
"name": "Answer_9NFPMZ",
"display": "September 1, 2014 03:00 PM - 04:00 PM",
"value": "09/01/2014~03:00:00 PM~04:00:00 PM"
}
]
}
]
}
I need to showcase the questions.text and underneath each one, display the questions.choices.display for all questions. Each question may have multiple answers. For example:
Q1 How are you?
A1 Feelin' Fine
A2 Fair
A3 Feelin' Bad
Q1 Where are you?
A1 Beach in Bahamas
A2 Broadway in New York
A3 Prison in Leavenworth
My dilemma lies in deciding the best approach to utilize ng-repeat in this scenario. Should I create a single array containing both the questions and their respective answers, or separate them into two arrays (one for questions, one for answers) and manage potential nesting issues? Any advice would be greatly appreciated.
Please note: I'm currently recovering from kidney stone surgery and under pain medication, which might cloud my judgment. Kindly refrain from overwhelming responses while I navigate through this haze. Thank you all for your understanding in advance.