Friday, 9 October 2020

AngularJS ng-repeat through complex and dynamic JSON Array

I am trying to display the contents to the user from JSON Array using the ng-repeat option. The JSON Array is created dynamically so I am bit confused how to display the same to users.

The syntax of the JSON ARRAY is as follows, the content of COMPLEX key can increase or decrease dynamically:

jsonList    =   [
                    {
                        name    :   "AB",
                        local   :   "CD",
                        complex :   [
                                        name    :   "EF",
                                        local   :   "GH",
                                        complex :   [
                                                        name    :   "IJ",
                                                        local   :   "LL".
                                                        complex :   ........
                                                    ]
                                    ]
                    },
                    {
                        name    :   "PQ",
                        local   :   "RS",
                        complex :   [
                                        name    :   "TU",
                                        local   :   "VW",
                                        complex :   [
                                                        name    :   "XY",
                                                        local   :   "Z1".
                                                        complex :   ........
                                                    ]
                                    ]
                    }
                    ......
                ];

I am just confused how can display this to users.

I want it to look something like this where the user has the option to add the complex values at every step using the Add Another option: enter image description here

I am really confused how to store the values in JSON Array automatically and loop though it using the ng-repeat and display to users automatically. Since the JSON Array is not fixed and can vary at every point, can someone please help me with some logic on how to proceed for this issue.

I tried to display in HTML Table but confused how to loop when there is so many complex objects.



from AngularJS ng-repeat through complex and dynamic JSON Array

No comments:

Post a Comment