从树材料中以原始格式获取数据

时间:2018-09-17 15:50:51

标签: angular tree angular-material2

我的应用程序中有可编辑的树状角度材质,但是我不知道如何将FileNode数组转换为原始格式。偶然有人已经经历过了吗?

原始格式:

{
  Groceries: {
    'Almond Meal flour': null,
    'Organic eggs': null,
    'Protein Powder': null,
    Fruits: {
      Apple: null,
      Berries: ['Blueberry', 'Raspberry'],
      Orange: null
    }
  },
  Reminders: [
    'Cook dinner',
    'Read the Material Design spec',
    'Upgrade Application to Angular'
  ]
};

FileNode格式:

[
    {
        "item":"Groceries",
        "children":[
            {"item":"Almond Meal flour"},
            {"item":"Organic eggs"},
            {"item":"Protein Powder"},
            {
                "item":"Fruits",
                "children":[
                    {"item":"Apple"},
                    {
                        "item":"Berries",
                        "children":[
                            {"item":"Blueberry"},
                            {"item":"Raspberry"}
                        ]
                    },
                    {"item":"Orange"}
                ]
            }
        ]
    },
    {
        "item":"Reminders",
        "children":[
            {"item":"Cook dinner"},
            {"item":"Read the Material Design spec"},
            {"item":"Upgrade Application to Angular"}
        ]
    }
]

这是一个令人眼花bl乱的例子:https://stackblitz.com/angular/gabkadkvybq?file=app%2Ftree-checklist-example.ts

0 个答案:

没有答案