ng-model deleted when pasting the same content to the editor
I've made a very basic plnkr to make this easy to test: http://plnkr.co/edit/PWh57DPNuks7rA5oI7r4
To reproduce, do:
-
Select editor contents with
ctrl-aand copy it to clipboard withctrl-c.
-
Press
ctrl-vto overwrite current selection. This will erase the ng-model contents, but in editor, everything looks all-right:
Tested on Ubuntu with Firefox 55.0.2 and Chromium 60.0.3112.78
I can confirm same issue. Tested with Angular v1.4.11 on Chrome 60.0.3112.101, OSX El Capitan.
I'm using this workaround to deal with this issue is to use the onChange event handler and check if action == 'insert' and ng-model is empty, I copy the lines to the ng-model like this:
on HTML:
<div ui-ace="aceOptions" ng-model="foo"></div>
on AceCtrl controller:
$scope.aceOptions = {
onChange: function (e) {
if (($scope.foo.length == 0) && (e[0].action == 'insert')) {
$scope.foo = e[0].lines[0];
}
}
}