我想創建一個TreeView數組以供在Angular UI樹中使用。我想從物體的陣列這樣創建結構:在Angular中創建對象的treeview數組
0:對象 體:空 categoryDescription:空 categoryTopic:空 描述:空 faqBodyId:0 faqCategoryId:0 faqGroupId:1 groupDescription:空 組名: 「Generelt」 groupTopic: 「Generelt」 themeCode: 「GEN」 話題:空
1:對象的身體:空categoryDescription: 「測試AF駕駛員學校」 categoryTopic:「郵件「description:null faqBodyId:0 faqCategoryId:2 faqGroupId:1 group描述:null組名:null組合主題:null主題:null : 「測試」 faqBodyId:3 faqCategoryId:2 faqGroupId:0 groupDescription:空組名:空groupTopic:空themeCode:空話題: 「Test123」
等等
這是三個層次。組,類別和身體 節點並不總是有一個孩子!
我想它在這個結構三個層次:
[
{
"id": 1,
"title": "1. dragon-breath",
"items": []
},
{
"id": 2,
"title": "2. moiré-vision",
"items": [
{
"id": 21,
"title": "2.1. tofu-animation",
"items": [
{
"id": 211,
"title": "2.1.1. spooky-giraffe",
"items": []
},
{
"id": 212,
"title": "2.1.2. bubble-burst",
"items": []
}
]
},
{
"id": 22,
"title": "2.2. barehand-atomsplitting",
"items": []
}
]
},
{
"id": 3,
"title": "3. unicorn-zapper",
"items": []
},
{
"id": 4,
"title": "4. romantic-transclusion",
"items": []
}
]
如何與角碼做了什麼?
那些看起來像標準JavaScript JSON陣列給我,但你的示例數據需要在這裏格式化,這很難理解這應該代表什麼。 – Claies 2015-02-10 14:13:53
這是JSON格式..對不起,我沒有提到這一點。這裏的編輯把它全部拉到一起..這有什麼竅門嗎? – 2015-02-10 14:53:05
根據您鏈接的文檔,Angular JS UI樹本身支持JSON數據。你有沒有嘗試你的數據,並有一些意外的結果? – Claies 2015-02-10 22:36:33