Skip to content

Commit

Permalink
use locals object to pass variables to the template's scope
Browse files Browse the repository at this point in the history
  • Loading branch information
scampi committed Mar 4, 2017
1 parent c9d5c0c commit 07b7549
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 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,7 +18,7 @@ export default function ($compile) {
interval: intervalTemplate,
filter: filterTemplate,
};
this.controllers = [];
this.locals = {};

this.addItems(opts);
}
Expand All @@ -36,8 +36,8 @@ 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.controller) {
this.controllers[opt.key] = opt.controller;
if (opt.locals) {
this.locals[opt.key] = opt.locals;
}
});
}
Expand Down Expand Up @@ -111,8 +111,8 @@ export default function ($compile) {
}

const $childScope = $scope.$new();
if (this.controllers[currentKey]) {
$childScope.controller = this.controllers[currentKey];
if (this.locals[currentKey]) {
Object.assign($childScope, this.locals[currentKey]);
}
const $el = $element.find('#template_wrapper').html(templateToRender).contents();
$compile($el)($childScope);
Expand Down

0 comments on commit 07b7549

Please sign in to comment.