Sha256: 32164b1f159443561cbfded5fc471f133ce5916b7bfca42bd7ecba72dcbc8a67
Contents?: true
Size: 1.1 KB
Versions: 22
Compression:
Stored size: 1.1 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] = _.uniq(_.union(this.menu[menuName], items), false, function (item) { return item.url; }, this); } else { this.menu[menuName] = items; } }; }]);
Version data entries
22 entries across 22 versions & 1 rubygems