diff --git a/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js b/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js index 4e8e6577881cc..7ab1efb94d0b7 100644 --- a/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js +++ b/src/ui/public/kbn_top_nav/kbn_top_nav_controller.js @@ -18,6 +18,7 @@ export default function ($compile) { interval: intervalTemplate, filter: filterTemplate, }; + this.locals = new Map(); this.addItems(opts); } @@ -35,6 +36,9 @@ export default function ($compile) { this.opts.push(opt); if (!opt.hideButton()) this.menuItems.push(opt); if (opt.template) this.templates[opt.key] = opt.template; + if (opt.locals) { + this.locals.set(opt.key, opt.locals); + } }); } @@ -107,6 +111,9 @@ export default function ($compile) { } const $childScope = $scope.$new(); + if (this.locals.has(currentKey)) { + Object.assign($childScope, this.locals.get(currentKey)); + } const $el = $element.find('#template_wrapper').html(templateToRender).contents(); $compile($el)($childScope);