Hi connoisseurs, I need help ... Through ul> li ng-repeat I bring out the menu. For the li element containing the condition in JSON (true), you need to add the data-uk-dropdown attribute for the jQuery plugin to work. Thank you in advance)
html
<nav ng-controller="MenuController as vm" > <ul> <li ng-repeat="item in vm.menu" ng-class="vm.getClass('{{ item.path }}') ? 'active' : '' || (item.submenu === true) ? 'parent' : ''" > <a href="{{ item.path }}">{{item.name}}</a> </li> </ul> </nav> Js
.controller('MenuController', MenuController) function MenuController($location, $http) { var vm = this; $http.get('menu.json').success(function(data) { vm.menu = data; vm.submenus = function(index) { var result = data[index].pages; return result; }; }; vm.getClass = function(path) { return ($location.path() === path) ? 'active' : ''; }; } Json
[{ "name": "Меню 1", "path": "/", "submenu": false }, { "name": "Меню 2", "path": "#", "submenu": true }, { "name": "Меню 3", "path": "/menu3", "submenu": false }]