为kendo编辑器角度模式创建自定义工具

时间:2016-05-26 07:26:44

标签: javascript jquery angularjs kendo-editor

我想在kendo编辑器中添加自定义工具。 通过指令在jQuery方法中相当不错,但是在模型绑定方面存在问题。

似乎我必须使用这样的角度方法:

<textarea naccordion id="htmleditor" ng-model="Model._Active.Paragraph" class="editor" k-options="accordion" k-encoded="false" kendo-editor k-tools="['fontName','bold','italic','underline','strikethrough','fontSize','justifyLeft','justifyCenter','justifyRight','justifyFull','foreColor','insertUnorderedList','insertOrderedList','indent','outdent','createLink','unlink','insertImage','cleanFormatting','backColor','viewHtml','formatting']"></textarea>

所以,我把我的k-options代码放在控制器中:

        $scope.accordion = {
        tools:
            {
                name: "accordion",
                tooltip: "Accordion items",
                exec: function (e) {
                    var editor = $(this).data("kendoEditor");
                    editor.exec("inserthtml", {
                        value: "<accordion close-others='true'><accordion-group is-open='Model._openSettings'><accordion-heading>[Title]</accordion-heading><br>[Text]</accordion-group></accordion>"
                    });
                }
            }

    };

这不行。 我不知道手风琴的范围是对还是不对? 有什么想法吗?

1 个答案:

答案 0 :(得分:0)

工具需要是一个数组:

 $scope.accordion = {
    tools:[
      {
       name: "accordion",
            tooltip: "Accordion items",
            exec: function (e) {
                var editor = $(this).data("kendoEditor");
                editor.exec("inserthtml", {
                    value: "<accordion close-others='true'><accordion-group is-open='Model._openSettings'><accordion-heading>[Title]</accordion-heading><br>[Text]</accordion-group></accordion>"
                });
            }
      }
    ]

};