Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

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

Closed
Madd0g opened this issue Sep 20, 2014 · 9 comments
Closed

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

Madd0g opened this issue Sep 20, 2014 · 9 comments

Comments

@Madd0g
Copy link

Madd0g commented Sep 20, 2014

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
Copy link

+1

@SummerSun
Copy link

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

@theBliz
Copy link

theBliz commented Dec 11, 2014

+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
Copy link
Contributor

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

@judytrinh
Copy link

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
Copy link

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
Copy link

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
Copy link

dduft commented Oct 20, 2016

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

@ym13349140
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants