Skip to content

Commit

Permalink
Navbarextensions improvements (#9871)
Browse files Browse the repository at this point in the history
* - added controller option
- added $location service to determine on which the user is at currently

* added test for the hideButton method that is dependent on the location path

* removed  argument

* use locals object to pass variables to the template's scope

* use map object
  • Loading branch information
scampi authored and spalger committed Mar 24, 2017
1 parent d18ca55 commit 590b6e0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ui/public/kbn_top_nav/kbn_top_nav_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function ($compile) {
interval: intervalTemplate,
filter: filterTemplate,
};
this.locals = new Map();

this.addItems(opts);
}
Expand All @@ -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);
}
});
}

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 590b6e0

Please sign in to comment.