1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 23:39:41 +02:00
portainer/app/portainer/components/code-editor/codeEditorController.js

21 lines
629 B
JavaScript
Raw Normal View History

angular.module('portainer.app')
.controller('CodeEditorController', ['$document', 'CodeMirrorService',
function ($document, CodeMirrorService) {
var ctrl = this;
this.$onInit = function() {
$document.ready(function() {
var editorElement = $document[0].getElementById(ctrl.identifier);
if (editorElement) {
ctrl.editor = CodeMirrorService.applyCodeMirrorOnElement(editorElement, ctrl.yml, ctrl.readOnly);
if (ctrl.onChange) {
ctrl.editor.on('change', ctrl.onChange);
}
if (ctrl.value) {
ctrl.editor.setValue(ctrl.value);
}
}
});
};
}]);