按键

时间:2018-06-07 12:32:57

标签: javascript angularjs angular-ui-tree

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

如何为每个节点汇总所有companyEstimatedEarning

例如,company 1.1.1 - total=5company 1.1 - total=18company 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': []
        }
    ]
}];

0 个答案:

没有答案
相关问题