angular-ui / ui-ace

This directive allows you to add ACE editor elements.
http://angular-ui.github.io/ui-ace
MIT License
578 stars 172 forks source link

setValue() doesn't work #147

Open sergomet opened 8 years ago

sergomet commented 8 years ago

editor:

        <div ng-model="html" ui-ace="{
          require: ['ace/ext/language_tools'],
          advanced: {
            enableEmmet:true,    
            enableSnippets: false,
          },
          useWrapMode : true,
          fontSize: '14px',
          splitMode : false,
          showGutter: true,
          theme:'monokai',
          mode: 'html',
          firstLineNumber: 5,
          onLoad: aceLoaded,
          onChange: bodyChanged
        }">

tried:

  $scope.aceLoaded = function(_editor) {
    var _session = _editor.getSession();
    _session.setValue('hello');  
  };

and:

  $scope.aceLoaded = function(_editor) {
    _editor.setValue('hello');  
  };

Expect this everything works nice, thanks!

ashish-agrawal-metacube commented 7 years ago

+1 facing the same issue

augustoeliezer commented 6 years ago

Use ngModel for it.

$scope.aceLoaded = function($editor) {

    $scope.$editor = $editor;
};

$scope.onOpen = function(code, fileExtension) {
    let mode = resolveExtension(fileExtension);
    $scope.html = code;
    $scope.$editor.session.setMode('ace/mode/' + mode);
}