Open prashant-pokhriyal opened 7 years ago
Store the editor from onLoad in $scope.
$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);
}
Excuse me for my poor inferring, but I'm not able to get you
Sorry I forgot add the service
$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);
}
I'm rendering content of the editor using $http service. But onLoad function is being called much before data is rendered in editor.
When I'm adding code inside
$timeout
service then it is working properly. Is there any way to achieve this without using $timeout service.