[英]How can I send an attribute to my directive with angular?
我正在為ckEditor使用以下HTML:
<textarea data-ck-editor="text" data-ng-model="modal.data.text"></textarea>
指示:
app.directive('ckEditor', [function () {
return {
require: '?ngModel',
link: function ($scope, elm, attr, ngModel) {
var ck = null;
var config = attr.editorSize;
var abc = attr.abc
var def = attr.def
if (config == 'wide') {
ck = CKEDITOR.replace(elm[0], { customConfig: 'config-wide.js' });
} else {
ck = CKEDITOR.replace(elm[0], { customConfig: 'config-narrow.js' });
}
從我的HTML中,如何為editorSize,abc和def發送值? 我可以將其作為
data-ck-editor="text
您已經完成了主要部分,只需添加諸如
<textarea data-ck-editor="text" data-ng-model="modal.data.text" editorSize="something" abc="something" def="something"></textarea>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.