首页 > 解决方案 > 如何使用 Angular 和 js 附加多个羽毛笔编辑器

问题描述

我想将多个羽毛笔编辑器附加到一个带有附加的 div 中。

目标是在帖子类型为 1 或 2 时附加合适的模板,并在羽毛笔编辑器中附加这些帖子的内容

但我不知道如何生成多个鹅毛笔编辑器,我试过这个:

    $http.post("/getwallpost", reqGetPost).then(function(response) {
         
        response.data.forEach(function(item) {

            if(item.type_id == 1) {
                var youp = "#" + item.id
                wallcontent.append("<div id='" + item.id + "'></div>");
                new Quill("#" + item.id, optionwall).setContents(JSON.parse(item.content));
                
            } else if(item.type_id == 2) {
                wallcontent.append('<div class="myArticles">This is article</div>');
            }
        });
       
    });

                                                                        
 <div id="wallcontent">
</div>

标签: javascriptangularjsquill

解决方案


没关系,它有效。

我使用数字作为 html id。我不得不使用像“#sqjdofjez”+ item.id 这样的字符,而不仅仅是“#5”


推荐阅读