On a new project with .net core and Angular 4 - I had to wait till a real database was in place.
Now that it IS there a DBA , along with a backend developer ended up a web api that I need to call and fetch a nested object with data that I had much simpler in arrays.
Current Data calls
Here is where I call a method to retrieve all the categories
getCategory() {
return [
new Category(1, 1, 'VAMC-Cat-1'),
new Category(2, 1, 'VAMC-Cat-2'),
new Category(3, 1, 'VAMC-Cat-3'),
new Category(4, 2, 'Vet-Cat-1'),
new Category(5, 2, 'Vet-Cat-2'),
new Category(6, 2, 'Vet-Cat-3'),
new Category(7, 3, 'Provider-Cat-1'),
new Category(8, 3, 'Provider-Cat-2'),
new Category(9, 3, 'Provider-Cat-3'),
new Category(10, 4, 'Other-Cat-1'),
new Category(11, 4, 'Other-Cat-2'),
new Category(12, 4, 'Other-Cat-3'),
new Category(13, 5, 'None-Cat-1'),
new Category(14, 5, 'None-Cat-3'),
new Category(15, 5, 'None-Cat-2'),
];
}
If you scroll down you can see that my single call for 3 cascading dropdowns is all in 1 big complex object. HOW can I make calls to this data that I need to persist in Angular4/typescript . Any ideas / examples ?
New Data that will return (swagger ui ) I used to call the web api
[
{
"customerTypeId": 1,
"customerTypeName": "VAMC",
"childCategories": [
{
"categoryId": 1,
"categoryName": "VAMC-Cat-1",
"customerTypeID": 1,
"childSubCategories": [
{
"subCategoryId": 1,
"subCategoryName": "VAMC-SubCat-1-1",
"categoryID": 1
},
{
"subCategoryId": 2,
"subCategoryName": "VAMC-SubCat-1-2",
"categoryID": 1
}
]
},
{
"categoryId": 2,
"categoryName": "VAMC-Cat-2",
"customerTypeID": 1,
"childSubCategories": [
{
"subCategoryId": 3,
"subCategoryName": "VAMC-SubCat-2-1",
"categoryID": 2
},
{
"subCategoryId": 4,
"subCategoryName": "VAMC-SubCat-2-2",
"categoryID": 2
}
]
}
]
},
{
"customerTypeId": 2,
"customerTypeName": "Vet",
"childCategories": [
{
"categoryId": 3,
"categoryName": "Vet-Cat-1",
"customerTypeID": 2,
"childSubCategories": [
{
"subCategoryId": 5,
"subCategoryName": "Vet-SubCat-1-1",
"categoryID": 3
},
{
"subCategoryId": 6,
"subCategoryName": "Vet-SubCat-1-2",
"categoryID": 3
}
]
},
{
"categoryId": 4,
"categoryName": "Vet-Cat-2",
"customerTypeID": 2,
"childSubCategories": [
{
"subCategoryId": 7,
"subCategoryName": "Vet-SubCat-2-1",
"categoryID": 4
},
{
"subCategoryId": 8,
"subCategoryName": "Vet-SubCat-2-2",
"categoryID": 4
}
]
}
]
},
{
"customerTypeId": 3,
"customerTypeName": "Provider",
"childCategories": [
{
"categoryId": 5,
"categoryName": "Provider-Cat-1",
"customerTypeID": 3,
"childSubCategories": [
{
"subCategoryId": 9,
"subCategoryName": "Provider-SubCat-1-1",
"categoryID": 5
},
{
"subCategoryId": 10,
"subCategoryName": "Provider-SubCat-1-2",
"categoryID": 5
}
]
},
{
"categoryId": 6,
"categoryName": "Provider-Cat-2",
"customerTypeID": 3,
"childSubCategories": [
{
"subCategoryId": 11,
"subCategoryName": "Provider-SubCat-2-1",
"categoryID": 6
},
{
"subCategoryId": 12,
"subCategoryName": "Provider-SubCat-2-2",
"categoryID": 6
}
]
}
]
},
{
"customerTypeId": 4,
"customerTypeName": "Other",
"childCategories": [
{
"categoryId": 7,
"categoryName": "Other-Cat-1",
"customerTypeID": 4,
"childSubCategories": [
{
"subCategoryId": 13,
"subCategoryName": "Other-SubCat-1-1",
"categoryID": 7
},
{
"subCategoryId": 14,
"subCategoryName": "Other-SubCat-1-2",
"categoryID": 7
}
]
},
{
"categoryId": 8,
"categoryName": "Other-Cat-2",
"customerTypeID": 4,
"childSubCategories": [
{
"subCategoryId": 15,
"subCategoryName": "Other-SubCat-2-1",
"categoryID": 8
},
{
"subCategoryId": 16,
"subCategoryName": "Other-SubCat-2-2",
"categoryID": 8
}
]
}
]
},
{
"customerTypeId": 5,
"customerTypeName": "None",
"childCategories": [
{
"categoryId": 9,
"categoryName": "None-Cat-1",
"customerTypeID": 5,
"childSubCategories": [
{
"subCategoryId": 17,
"subCategoryName": "None-SubCat-1-1",
"categoryID": 9
},
{
"subCategoryId": 18,
"subCategoryName": "None-SubCat-1-2",
"categoryID": 9
}
]
},
{
"categoryId": 10,
"categoryName": "None-Cat-2",
"customerTypeID": 5,
"childSubCategories": [
{
"subCategoryId": 19,
"subCategoryName": "None-SubCat-2-1",
"categoryID": 10
},
{
"subCategoryId": 20,
"subCategoryName": "None-SubCat-2-2",
"categoryID": 10
}
]
}
]
}
]