I have an object from a service like below
let obj = [
0: {
key1: 'val',
key2: 'val',
key3: [{
key1: 'val',
key2: 'val',
key3: [];
}]
}
1: {
key1: 'val',
key2: 'val',
key3: [{
key1: 'val',
key2: 'val',
key3: [];
}]
}
]
the index can be more than 2 arrays, it an be upto 10 or more. I need to iterate over the index and the keys/value of their objects.
The outcome should be key1: val key2: val
and once I hit key3 the output should be key1: val key2: val
I've tried getting the keys for the obj using Object.keys(obj), but that only returns 0 and 1. How can I get the keys of the inner objects, and render keys/values inside of my angular template?
<div *ngFor="let key of obj">
{{key +': '+ obj[key]}}
<div>
doesn't work. the additional issue with the template above is it doesn't take into account the deeply nested object and its key/value pair.
Any help here would be appreciated. If anything is confusing please ask for clarification.