Reputation: 169
{
"Petition to file": [
{
"description": "fileing description",
"period": "30 days",
"fees": "500"
}
],
"Appearing before inspection": [
{
"description": "Appearence Description",
"period": "10 days",
"fees": "1500"
}
],
"Passing orders for a recording of statements": [
{
"description": "passing order description",
"period": "50 days",
"fees": "1000"
}
],
"Hearing of petition": [
{
"description": "Hearing of petition description",
"period": "55 days",
"fees": "2000"
}
],
"Decree of petition": [
{
"description": "decreeof description",
"period": "70 days",
"fees": "5000"
}
]
}
How to get the values of nested child headings. It is dynamic content .Also i need to fetch the values of nested objects that is period,fess,description . I'm using typescript program that is in angular cli
Upvotes: 0
Views: 149
Reputation: 3387
here is complete working example StackBlitz Link, Your main logic of traversing dynamic object entries is...
ngOnInit(){
Object.keys(this.datafromDatabase).forEach(data =>{
this.datafromDatabase[data].map(key =>{
this.data.push(key)
});
})
}
Your Template file is...
<div *ngFor="let key of data">
{{key.description}}
</div>
<div>
{{data |json}}
</div>
Upvotes: 1
Reputation: 3386
let list = {
"Petition to file": [
{
"description": "fileing description",
"period": "30 days",
"fees": "500"
}
],
"Appearing before inspection": [
{
"description": "Appearence Description",
"period": "10 days",
"fees": "1500"
}
],
"Passing orders for a recording of statements": [
{
"description": "passing order description",
"period": "50 days",
"fees": "1000"
}
],
"Hearing of petition": [
{
"description": "Hearing of petition description",
"period": "55 days",
"fees": "2000"
}
],
"Decree of petition": [
{
"description": "decreeof description",
"period": "70 days",
"fees": "5000"
}
]
}
for (let [key, value] of Object.entries(list)) {
console.log(key);
console.log(value);
}
Use Object.entries
Upvotes: 0
Reputation: 39
var something = consts['Petition to file'];
usually thats the way to get the values inside keys
so now the new variable something
=
[
{
"description": "fileing description",
"period": "30 days",
"fees": "500"
}
]
now if u want description
var descriptionVariable = consts['description'];
so descriptionVariabe's value is fileing description
Upvotes: 0