1

anglar-ui-tree在我的项目中使用。

如何companyEstimatedEarning对每个节点求和?

例如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': []
        }
    ]
}];
4

0 回答 0