Skip to content

Commit

Permalink
Set up mode setting as two-way binding so it can be changed on the fly
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed May 10, 2013
1 parent b026ad1 commit 2265c52
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion hawtio-web/src/main/webapp/app/ui/js/editorDirective.ts
Expand Up @@ -9,7 +9,8 @@ module UI {

public scope = {
text: '=hawtioEditor',
name: '@',
mode: '=',
name: '@'
};

public controller = ($scope, $element, $attrs) => {
Expand Down Expand Up @@ -65,6 +66,7 @@ module UI {
delete config['$attr'];
delete config['class'];
delete config['hawtioEditor'];
delete config['mode'];

angular.forEach(config, function(value, key) {
$scope.options.push({
Expand All @@ -73,6 +75,19 @@ module UI {
});
});

$scope.$watch('mode', () => {
if ($scope.mode) {
if (!$scope.codeMirror) {
$scope.options.push({
key: 'mode',
'value': $scope.mode
});
} else {
$scope.codeMirror.setOption('mode', $scope.mode);
}
}
});

$scope.$watch('text', function() {
if (!$scope.codeMirror) {

Expand Down

0 comments on commit 2265c52

Please sign in to comment.