我使用了以下 HTML:
<textarea style="height: 350px; width: 100%"
data-ck-editor="text" id="editor-1"
data-ng-disabled="modal.action=='delete'"
data-ng-model="modal.data.text"></textarea>
而这个指令:
app.directive('ckEditor', [function () {
return {
require: '?ngModel',
link: function ($scope, elm, attr, ngModel) {
ck = CKEDITOR.replace(elm[0]);
...
...
现在设置好了,我想在指令之外从我的 javascript 向 ckEditor 发送一个命令。像这样:
editor1.setData('xxx');
知道创建它的指令是基于带有 id="editor-1" 的 textarea 时,我如何才能找到 ckEditor 对象(例如 editor1)?