I am new to Angular JS.
My JSON data is:
{
"CheckList": [
{
"UnitClass": "Budget Space",
"CheckListCategoryId": 1,
"CheckListCategory": "DOORS",
"CheckListItemId": 2,
"CheckListItem": "Deadbolt, Locksets, and keys all functioning"
},
{
"UnitClass": "Budget Space",
"CheckListCategoryId": 2,
"CheckListCategory": "WINDOWS",
"CheckListItemId": 46,
"CheckListItem": "Windows are operable"
},
{
"UnitClass": "Budget Space",
"CheckListCategoryId": 2,
"CheckListCategory": "WINDOWS",
"CheckListItemId": 13,
"CheckListItem": "Window pane is not broken or cracked"
}
}
And I want to change it to:
{
"CheckList": [
{
"UnitClass": "Budget Space",
"CheckListCategoryId": 1,
"CheckListCategory": "DOORS",
"CheckListItemId": 2,
"CheckListItem": "Deadbolt, Locksets, and keys all functioning"
},
{
"UnitClass": "Budget Space",
"CheckListCategoryId": 2,
"CheckListCategory": "WINDOWS",
"CheckListItems": [
{
"CheckListItem": "Windows are operable",
"CheckListItemId": 46,
},
{
"CheckListItem": "Window pane is not broken or cracked",
"CheckListItemId": 13,
}]
}
}
Why I am doing this:
I have a Bootstrap collapse list as
DOORS
WINDOWS
which i am getting using ng-repeat, adding a filter 'unique' on CheckListCategoryId
But the problem is with my current JSON, only single CheckListItem is getting posted but in many cases there are two. like in WINDOWS.
How to change the JSON data??
One more thing. Is my current way correct or there is any other alternative??