首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >bootstrap-wysihtml5 Angular Directive在更改时未正确更新

bootstrap-wysihtml5 Angular Directive在更改时未正确更新
EN

Stack Overflow用户
提问于 2013-01-29 06:51:36
回答 1查看 5.1K关注 0票数 3

我目前正在尝试使用带有Angular指令的wysihtml5,但是我似乎无法正确地触发change事件。

下面是我设置的指令:

代码语言:javascript
复制
app.directive('wysiwyg', ['$parse', function() {
 return {
    restrict: "A",
    require: "?ngModel",
    link: function(scope, element, attrs, ctrl) {

        var change = function() {
            scope.$apply(function(){
                ctrl.$setViewValue($(element).val());
            });
        };

        $(element).wysihtml5({
            "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true
            "emphasis": true, //Italics, bold, etc. Default true
            "lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
            "html": false, //Button which allows you to edit the generated HTML. Default false
            "link": true, //Button to insert a link. Default true
            "image": true, //Button to insert an image. Default true,
            "color": false, //Button to change color of font
            "events": {
                "change": function() {
                    window.console.log("changed");
                    change();
                },
                "newword:composer": function() {
                    change();
                },
                "paste": function() {
                    change();
                }
            }
        });
    }
 };
}]);

根据wysihtml5的文档,这就是监听change元素的方式。然而,它目前只在模糊时触发,而不是在编辑器发生更改时触发。有没有我应该寻找的不同事件,或者我应该用Angular指令以不同的方式来做这件事?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-24 18:20:42

你试过这个指令了吗?https://gist.github.com/joshkurz/3300629

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14572733

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档