Adds ability for parent controller to call atCodeMirror's init() function.

This enables the parent controller to re-instantiate the CodeMirror instance
on the fly, when necessary. This was necessary on the NetworkUI to update the
CodeMirror instance on the Host Detail panel.
This commit is contained in:
Jared Tabor
2018-04-20 17:14:18 -07:00
parent 19ebaa6916
commit 0b4d88a57d
3 changed files with 16 additions and 7 deletions
@@ -1,6 +1,5 @@
const templateUrl = require('~components/code-mirror/code-mirror.partial.html');
const CodeMirrorEventListener = 'CodeMirror-init';
const CodeMirrorID = 'codemirror-extra-vars';
const CodeMirrorModalID = '#CodeMirror-modal';
const ParseVariable = 'parseType';
@@ -43,10 +42,10 @@ function atCodeMirrorController (
vm.expanded = false;
vm.close = close;
vm.expand = expand;
if ($scope.init) {
$scope.init = init;
}
init($scope.variables);
$scope.$on(CodeMirrorEventListener, (e, vars) => {
init(vars);
});
}
atCodeMirrorController.$inject = [
@@ -70,7 +69,8 @@ function atCodeMirrorTextarea () {
labelClass: '@',
tooltip: '@',
tooltipPlacement: '@',
variables: '@'
variables: '@',
init: '='
}
};
}