Sha256: b554e7c6c4655d3d37cee233ec2db396d55fa947c2691bc81576c332b3221a2e
Contents?: true
Size: 1.09 KB
Versions: 214
Compression:
Stored size: 1.09 KB
Contents
/** * @ngdoc service * @name Bastion.menu.service:menuExpander * * @description * Provides a way to add additional menu items from other modules. * * Expects menus to be an array of objects of the form: * {url: 'http://redhat.com', label: 'Red Hat'} * * @usage * angular.module('SomeOtherModule', ['Bastion.menu']); * * angular.module('SomeOtherModule').run(['MenuExpander', function (menuExpander) { * menuExpander.setMenu('system', [{'url': 'http://redhat.com', 'label': 'Red Hat'}]); * }]); */ angular.module('Bastion.menu').service('MenuExpander', [function () { this.menu = {}; this.getMenu = function (menuName) { if (this.menu.hasOwnProperty(menuName)) { return this.menu[menuName]; } return []; }; this.setMenu = function (menuName, items) { if (this.menu.hasOwnProperty(menuName)) { this.menu[menuName] = _.uniqBy(_.union(this.menu[menuName], items), function (item) { return item.url; }); } else { this.menu[menuName] = items; } }; }]);
Version data entries
214 entries across 214 versions & 2 rubygems