I use anglar-ui-tree
in my project.
How can I sum all companyEstimatedEarning
for each node?
For example, company 1.1.1
- total=5
, company 1.1
- total=18
, company 1
- total=53
$scope.data = [{
'id': 1,
'title': 'company1',
'companyEstimatedEarning': 25,
'nodes': [
{
'id': 11,
'title': 'company1.1',
'companyEstimatedEarning': 13,
'nodes': [
{
'id': 111,
'title': 'company1.1.1',
'companyEstimatedEarning': 5,
'nodes': []
}
]
},
{
'id': 12,
'title': 'company1.2',
'companyEstimatedEarning': 10,
'nodes': []
}
]
}, {
'id': 2,
'title': 'company2',
'companyEstimatedEarning': 10,
'nodes': [
{
'id': 21,
'title': 'company2.1',
'companyEstimatedEarning': 15,
'nodes': []
}
]
}];