我有以下代码:
app.directive('ckEditor', [function () {
return {
require: '?ngModel',
link: function ($scope, elm, attr, ngModel) {
var ck = null;
var config = attr.ckSize;
ck = CKEDITOR.replace(elm[0]);
if (config == 'narrow') {
ck.resize(700, 357);
} else {
ck.resize(900, 357);
}
我正在尝试调整ckEditor实例的大小,但它给出了一条错误消息:
TypeError: Cannot call method 'setSize' of undefined
at CKEDITOR.editor.resize (http://127.0.0.1:81/Scripts/ckeditor/ckeditor.js:294:23)
有人可以就如何更改该编辑器大小的实例给出建议吗?
答案 0 :(得分:1)
这是来自here的创建实例代码:
function createEditor()
{
if ( editor )
return;
var html = document.getElementById( 'editorcontents' ).innerHTML;
// Create a new editor inside the <div id="editor">, setting its value to html
var config = {};
editor = CKEDITOR.appendTo( 'editor', config, html );
}
确保代码中存在id ='editorcontents'的div:
<div id='editorcontents'></div>
在help page的底部,您尝试了width
属性:
ck.width = 700;
ck.height = 357;