When starting a new project involving .net core and Angular 4, I had to wait for the implementation of a real database.
Now that the database is in place, a DBA and backend developer have created a web api from which I need to retrieve a nested object containing data that was previously stored in simple arrays.
Current Data calls
Here is where I execute a method to fetch 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'),
...
// additional entries omitted for brevity
];
}
In order to display three cascading dropdowns, I now require a single call that returns a complex object. How can I make these calls and persist the data in Angular 4/typescript? Any ideas/examples?
New Data retrieved using Swagger UI from the web api:
[
{
"customerTypeId": 1,
"customerTypeName": "VAMC",
"childCategories": [
{
"categoryId": 1,
...
// additional entries omitted for brevity
}
]
},
...
// additional entries omitted for brevity
}
]
}
]