我是新來的angular js。我需要使用angular js創建一個動態菜單和超鏈接。 我有菜單名稱和超鏈接來自json,我需要顯示。 目前我已經嘗試過使用靜態菜單。Angular js使用json創建動態菜單
我的菜單結構是這樣
Home
Services
-ser1
-ser2
-ser3
About
-abt1
Contact
所有菜單值和超鏈接來自JSON文件。
這是我的JSON
[
{
"id": 100,
"product": 0,
"childs": [
{
"id": 200,
"description": {
"id": 0,
"name": "Home",
"url": "home"
}
}
]
},
{
"id": 100,
"description": {
"id": 0,
"name": "services",
"url": "services"
},
"parent": null,
"childs": [
{
"id": 200,
"description": {
"id": 0,
"name": "Ser1",
"url": "Ser1"
},
"productCount": 0,
"childs": [
{
"id": 250,
"description": {
"id": 0,
"name": "ser2",
"url": "Ser2"
},
"childs": []
},
{
"id": 251,
"description": {
"id": 0,
"name": "ser3",
"url": "ser3"
},
"productCount": 0,
"childs": []
}
]
}
]
},
{
"id": 201,
"description": {
"id": 0,
"name": "About",
"url": "about"
},
"productCount": 0,
"childs": [
{
"id": 203,
"description": {
"id": 0,
"name": "abt1",
"url": "underground"
},
"productCount": 0,
"childs": []
}
]
},
{
"id": 202,
"description": {
"id": 0,
"name": "Contact",
"url": "con"
},
"productCount": 0,
"childs": []
}
]
這是我的HTML
<li class="prod-dropdown" ng-repeat="menu in menus" ng-class="{proddropdown: menu.menus}">
<a ng-href="#/{{menu.action}}" ng-class="{'dropdown-toggle': menu.menus}"
data-toggle="dropdown">{{menu.menus.desc['name']}} </a>
<ul ng-if="menu.menus" class="dropdown-menu">
<li ng-repeat="submenu in menu.menus">
<a ng-href="#/{{submenu.action}}">{{submenu.desc}}</a>
</li>
</ul>
</li>
什麼你想要做什麼?你甚至沒有在json和html中定義的單個匹配屬性 – nikhil
這些值將來自php後端,他們正在動態創建json。這是針對電子商務網站 – user2959949
我不是在談論值,而是屬性。例如,在json中,我找不到任何動作 – nikhil