I have a treeview using angular-tree-component as use of following link Refernece
Where the array is in below format:
nodes = [
{
id: 1,
name: 'root1',
children: [
{ id: 2, name: 'child1' },
{ id: 3, name: 'child2' }
]
},
{
id: 4,
name: 'root2',
children: [
{ id: 5, name: 'child2.1' },
{
id: 6,
name: 'child2.2',
children: [
{ id: 7, name: 'granchild 2.2.1' }
]
}
]
}
];
But I have a json nested array in the below format:
[
{
"name": "root1",
"subCategory": [
{
"name": "child1",
"childCategory": []
},
{
"name": "child2",
"childCategory": []
}
]
},
{
"name": "level2",
"subCategory": [
{
"name": "level2.1",
"childCategory": []
},
{
"name": "level2.2",
"childCategory": [
{
"name": "granchild 2.2.1",
"type": "checkbox"
}
]
}
]
}
]
My doubts are below:
- How can I convert json to required array Format which is acceptable by the angular-tree-component
- As you can see the type is checkbox
{"name": "granchild 2.2.1","type": "checkbox"}. So the grandchild 2.2.1 should be a check box and if it was radio button it should be radio.
Please guide me...
typeshoud be placed?