title: Updating textarea value with CKEditor content in Angular JS
body: <p>I am using latest CKEditor (Standard Version) and based on this
  <a href="https://stackoverflow.com/questions/11997246/bind-ckeditor-value-to-model-text-in-angularjs-and-rails">question</a> , I have implemented an angular directive like this,</p>
  
  <pre><code>var cmsPlus = angular.module('cmsPlus', []);
  
  cmsPlus.directive('ckEditor', function() {
    return {
      require: '?ngModel',
      link: function(scope, elm, attr, ngModel) {
        var ck = CKEDITOR.replace(elm[0]);
  
        if (!ngModel) return;
  
        ck.on('pasteState', function() {
          scope.$apply(function() {
            ngModel.$setViewValue(ck.getData());
          });
        });
  
        ngModel.$render = function(value) {
          ck.setData(ngModel.$viewValue);
        };
      }
    };
  });
  </code></pre>
  
  <p>It's working fine when I am typing something in CKEditor GUI mode, here I am getting the typed content to textarea's ng-model. </p>
  
  <p>But when I am switching to code-editor, it's not getting the updated content even after switch back to GUI. It's required to type something again in graphical mode.</p>
  
  <p>What is wrong with my directive? Or can I extend this directive with some other CKEditor events?</p>
  
  <p>I want add some more events for form submit or something else.</p>
  
  <p><strong><em><a href="http://jsfiddle.net/fdD63/1/" rel="nofollow noreferrer">Demo here.</a></em></strong></p>