简体   繁体   English

如何使用angular向我的指令发送属性?

[英]How can I send an attribute to my directive with angular?

I am using this HTML for my ckEditor: 我正在为ckEditor使用以下HTML:

<textarea data-ck-editor="text" data-ng-model="modal.data.text"></textarea>

Directive: 指示:

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' });
            }

From my HTML, how can I send a value for editorSize, abc and def ? 从我的HTML中,如何为editorSize,abc和def发送值? Could I send this as part of the 我可以将其作为

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.

相关问题 #Angular2如何计算自定义属性指令的数量? - #Angular2 How i can count numbers of custom attribute directive? 如何使用动态名称创建Angular 2自定义属性指令? - How can I create Angular 2 custom attribute directive with dynamic name? 如何动态更新角度指令属性? - How can I update an angular directive attribute dynamically? 如何在Angular指令中监听元素的属性更改? - How can I listen an element's attribute change in an Angular directive? 如何发送到模型的角度指令参考,而不是复制 - How can I send to angular directive reference of model, not copy 如何通过Angular 6指令将camelcase属性添加到dom元素? - How can I add a camelcase attribute to a dom element via an Angular 6 directive? 如何使用Angular在表单内部访问兄弟指令的属性 - How can I access an attribute of a sibling directive inside of a form using Angular 如何使用Angular指令强制将Google Maps加载到我的Angular应用中 - How can I force Google Maps to load in my Angular app using an Angular Directive 如何在我的angularjs指令中切换诸如contenteditable之类的属性的值? - How can i toggle the value of an attribute like contenteditable in my angularjs directive? 如何在自定义指令中的某些标记上设置 ng-change 属性? - How can I set the ng-change attribute on some mark up inside my custom directive?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM