mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Merge pull request #7976 from tsullivan/render-directive-controller-context
render directive: add controller context
This commit is contained in:
commit
7b1ac9884d
1 changed files with 11 additions and 3 deletions
|
@ -38,7 +38,7 @@ uiModules
|
|||
template: function ($el, $attrs) {
|
||||
return $el.html();
|
||||
},
|
||||
controller: function ($scope, $element, $attrs, $transclude) {
|
||||
controller: function ($scope, $element, $attrs, $transclude, $injector) {
|
||||
if (!$scope.definition) throw new Error('render-directive must have a definition attribute');
|
||||
|
||||
const { controller, controllerAs, scope } = $scope.definition;
|
||||
|
@ -46,8 +46,16 @@ uiModules
|
|||
applyScopeBindings(scope, $scope, $attrs);
|
||||
|
||||
if (controller) {
|
||||
if (controllerAs) $scope[controllerAs] = this;
|
||||
$scope.$eval(controller, { $scope, $element, $attrs, $transclude });
|
||||
if (controllerAs) {
|
||||
$scope[controllerAs] = this;
|
||||
}
|
||||
|
||||
const locals = { $scope, $element, $attrs, $transclude };
|
||||
const controllerInstance = $injector.invoke(controller, this, locals) || this;
|
||||
|
||||
if (controllerAs) {
|
||||
$scope[controllerAs] = controllerInstance;
|
||||
}
|
||||
}
|
||||
},
|
||||
link: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue