I am new to angular js .I need to create a dynamic menu and hyperlink using angular js. I have menu name and hyperlink coming from json and i need to display. Currently i have tried with static menus which is working.
My menu structure is like
Home
Services
-ser1
-ser2
-ser3
About
-abt1
Contact
All the menu values and hyperlink comes from json file.
This is my 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": []
}
]
And this is my 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>