在Angularjs指令中配置CkEditor工具栏

时间:2016-01-19 10:11:38

标签: javascript jquery angularjs

我有CkEditor的指令。我只需要在指令中配置ckeditor工具栏,需要帮助......这是我的指令

.directive('fosCkEditor', ['$compile',
function($compile) {
    return {
        require: '?ngModel',
        link: function ($scope, elm, attr, ngModel) {

            var ck = CKEDITOR.replace(elm[0]);

            ck.on('pasteState', function () {
                $scope.$apply(function () {
                    ngModel.$setViewValue(ck.getData());
                });
            });

            ngModel.$render = function (value) {
                ck.setData(ngModel.$modelValue);
            };
        }
    };

}
]);

1 个答案:

答案 0 :(得分:0)

为什么不使用 ng-ckeditor ?:

http://issuetracker.unity3d.com/issues/particle-system-plays-only-once

来自ng-ckeditor docs:

<textarea ckeditor="editorOptions" ng-model="modelName"></textarea>
// add dependency
angular.module('app', ['ngCkeditor'])

// setup editor options
$scope.editorOptions = {
    language: 'ru',
    uiColor: '#000000'
};