Is there a way to tell if the onchange is coming from a ng-model change or user typing?
I'm using json editing with ace and updating an object on my scope every time the editor changes. Then I have a checkbox that a user can click to update a boolean in the object. I then reflect this in the ace editor.
Because I can't use databinding - I need to keep the values in sync manually with JSON.stringify/JSON.parse. This becomes a problem because the editor sends the onChange event even if the change comes from changing the scope value.
Is there a way of getting an event only when the ace editor changes by user input. How difficult would it be to add it? Any ideas how I can sidestep this problem?
Thanks
I have a similar problem. I want to implement auto save using ace but the onChange event is called also when loading the editor with ng-model. I think that the behavior should be the same as the HTML input element where onChange is fired only if the user change the text. What do you think?
For now I have implemented auto save using onBlur.
thanks
You can use
editor.getSession().on('change', function() { // do something });
Where editor is the ace instance obtained using the onLoad event in the ui-ace attribute
<div ui-ace="{onLoad: onAceLoad}" ng-model="model"></div>
scope.onAceLoad = function (editor) {
editor.getSession().on('change', function() { // do something });
}