I can't take credit for writing this code, found it on http://stackoverflow.com/questions/11997246/bind-ckeditor-value-to-model-text-in-angularjs-and-rails/12021632#12021632
angular.module('yourApp').directive('ckEditor',function () {
return {
require: '?ngModel',
link: function (scope, elm, attr, ngModel) {
var ck = CKEDITOR.replace(elm[0],
{
toolbarGroups: [
{ name: 'clipboard', groups: ['clipboard', 'undo'] },
{ name: 'basicstyles', groups: ['basicstyles', 'cleanup'] }
]
}
);
if (!ngModel) return;
ck.on('pasteState', function () {
scope.$apply(function () {
ngModel.$setViewValue(ck.getData());
});
});
ngModel.$render = function (value) {
ck.setData(ngModel.$viewValue);
};
}
};
});
