title: Implement CKEditor with AngularJS (pasteState event)
body: <p>I use CKEditor in my AngularJS webapp. I defined the event <code>pasteState</code> to listen to text changes and copy it to my <code>ng-model</code>. </p>
  
  <p>Today, I upgraded CKEditor from version <code>4.4.7</code> to <code>4.5.1</code> (the last one) and discovered that my <code>pasteState</code> event is never fired.</p>
  
  <p><strong>My directive with the <code>change</code> event:</strong></p>
  
  <pre><code>appDrct.directive('ckEditor', function() {
      return {
          require: '?ngModel',
          link: function($scope, $elm, attr, ngModel) {
  
              var config = {
                  toolbar:[[ 'Bold', 'Italic', 'Underline', 'Strike', 'TextColor', 'FontSize', '-', 'JustifyLeft', 'JustifyRight' ]]
              };
              config.removeButtons = '';
              config.fontSize_sizes = 'petit/12px;normal/14px;grand/16px;';
  
              var ck = CKEDITOR.inline ($elm[0], config);
  
              if (!ngModel) return;
  
              //ck.on('pasteState', function() {
              ck.on('change', function() {
                  console.log(ck.mode);
                  $scope.$apply(function() {
                      ngModel.$setViewValue(ck.getData() || '');
                  });
              });    
  
              ngModel.$render = function (value) {
                  ck.setData(ngModel.$viewValue);
              };
  
              $scope.$on("$destroy",function() {
                  CKEDITOR.instances[ck.name].destroy();
              });
          }
      };
  });
  </code></pre>