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

Changing value on the $scope not updating the editor? #64

Closed Madd0g closed 9 years ago

Madd0g commented 10 years ago

Hi,

I was a bit surprised to find out that when I update the $scope variable, the editor does not update. Do I need to call some update method? Does that mean I need to save the editor from the onLoad event? Or is there something I can inject into my controller?

I'm wondering why this is not built-in.

Thanks

markokristian commented 9 years ago

+1

SummerSun commented 9 years ago

+1 I user to bind the edit content, the content changed, but the editor area won't refresh until mouse click.

theBliz commented 9 years ago

+1 I have the same issues " the content changed, but the editor area won't refresh until mouse click." I also tried to solve it by simulating a click with jQuery but it doesn't work. Someone's got a solution?

douglasduteil commented 9 years ago

Can you confirm that it's fixed with #87 #77 ?

judytrinh commented 8 years ago

I still have this issue, using the latest version 0.2.3. I have a uib-tabset, and in tab no.1 I have a ui-ace div where I type text to update the ng-model. In tab no.2, I have a readonly ui-ace div that should reflect what I have changed because it has the same ng-model as the first. When I switch to tab no.2, the ui-ace does not update until I click into it or trigger other events like a tooltip hover over outside of the tabset, etc. If I place the readonly ui-ace input in tab no.1, however, it updates just fine. If I place the ng-model variable in between {{}} in tab no.2, it updates just fine. So, I think it is a similar issue discussed in this thread.

I am aware of this issue with tabsets: http://stackoverflow.com/questions/27513462/angularjs-ngmodel-doesnt-work-inside-a-ui-bootstrap-tabset I am not using a primitive on the scope for my ng-model -- I am using an object attached to my controller referencing it with the help of controllerAs. So I'm not sure what could be the issue. Any ideas?

judytrinh commented 8 years ago

An fyi, I managed to temporarily fix the issue with a hack where I call a $timeout( function() { $rootScope.$broadcast('update-ace-editor-hack'); } ) upon clicking tab no.2 so that the editor receives an event to trigger its refresh.

Edit: actually, it seems that all that isn't even necessary - just putting ng-click directive on the uib-tab element triggers the refresh itself.

janzhongi commented 8 years ago

before find a better solution,I fixed in this way. run aceEditor.setValue() will update the editor content. first you need to get the editor in ui-ace.onload function $scope.editor; $scope.aceLoaded = function (_editor) { ... $scope.editor = _editor; .... }

and use $scope.aceEditor.setValue(newValue) to trigger the refresh;

dduft commented 7 years ago

This is not solved! Thank you judytrinh for the hack! But for me the broadcast was necessary as well.

ym13349140 commented 6 years ago

I met with this problem too,and I used editor.renderer.updateFull(); worked.