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

ng-model deleted when pasting the same content to the editor #176

Open
vrockai opened this issue Aug 25, 2017 · 1 comment
Open

ng-model deleted when pasting the same content to the editor #176

vrockai opened this issue Aug 25, 2017 · 1 comment

Comments

@vrockai
Copy link

vrockai commented Aug 25, 2017

I've made a very basic plnkr to make this easy to test: http://plnkr.co/edit/PWh57DPNuks7rA5oI7r4

To reproduce, do:

  1. Select editor contents with ctrl-a and copy it to clipboard with ctrl-c.
    image

  2. Press ctrl-v to overwrite current selection. This will erase the ng-model contents, but in editor, everything looks all-right:
    image

Tested on Ubuntu with Firefox 55.0.2 and Chromium 60.0.3112.78

@gerzenstl
Copy link

gerzenstl commented Sep 1, 2017

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];
      }
    }
}

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

2 participants