0
我使用下面的代碼使用angularjs指令顯示ckeditor。但它不會顯示在頁面中。Ckeditor角度指令不起作用
指令:
'use strict';
define('ngCkeditor', ['app'], function (app) {
app.directive('ngCkeditor', function() {
return {
restrict: 'AC',
require: 'ngModel',
link: function (scope, element, attr, ngModel) {
debugger;
var ck = CKEDITOR.replace(element[0]);
if (!ngModel) return;
ck.on('pasteState', function() {
scope.$apply(function() {
ngModel.$setViewValue(ck.getData());
});
});
ngModel.$render = function (value) {
ck.setData(ngModel.$viewValue);
};
}
};
});
});
和控制器:
define('ckEditorController', ['app', 'ckeditor', 'ckfinder', 'ngCkeditor'], function (app, ckeditor, ckfinder, ngCkeditor) {
app.lazy.controller('ckEditorController', ['$scope', '$location', function ($scope, $location) {
debugger;
$scope.text = 'this is test';
}]);
});
,這是HTML:
<link href="~/app/lib/editor/css/bootstrap.css" rel="stylesheet" />
<link href="~/app/lib/editor/ng-ckeditor.css" rel="stylesheet" />
<h2>CkEditor</h2>
<form name="frm">
<div ng-controller="ckEditorController">
<textarea class="ng-Ckeditor" ng-model="text"></textarea>
<textarea ng-ckeditor ng-model="text"></textarea>
<h3>Result HTML:</h3>
<div ng-bind-html-unsafe="text"></div>
</div>
在我看來,在指令中的鏈接部分不冷杉e。
感謝
更新:
看看jsfiddle鏈接。它像一個魅力。但我的不
你能否提供給我更多的細節! –
不,它不適用於「ng-ck-editor」 –
如果您命名ngCkeditor指令,它應該是ng-ckeditor。 – dfsq