Eliézer
Eliézer
Store the editor from onLoad in $scope. ```javascript $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/' +...
Sorry I forgot add the service ```javascript $scope.openFile = function(file) { //Here I prefer use factory. //fileFactory.openFile(file).then(fn,fn); $http.post('/api', file).then(function (res) { $scope.onOpen( res.data.content, res.data.extension) },angular.noop); } ```
Use ngModel for it. ```javascript $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); } ```