0

我通过创建 quill 的新实例和创建自定义工具栏在 Angular 中实现了 quill 编辑器。

    this.quill = new Quill('#editor-container', {
        modules: {
            toolbar: '#toolbar-container'
        },
        theme: 'snow' // or 'bubble'
    });

我有一个“更新”按钮,可以调用更新 API。我需要检查 Quill 编辑器的内容是否发生了变化。我知道 quill.on('text-change'):

    this.quill.on('text-change', function(delta, oldDelta, source) {
        if (source == 'api') {
            console.log('An API call triggered this change.');
        } else if (source == 'user') {
            console.log('A user action triggered this change.');
        }
    });

但是,我不确定我应该把它放在哪里?NgOnInit? NgAfterViewInit? 我在 ngAfterViewInit 中创建了 quill 实例。我知道这可能是一个愚蠢的问题。

任何帮助表示赞赏!谢谢!:)

4

1 回答 1

-1

您可以将其放在模块/组件的构造函数中。

于 2020-11-17T07:19:08.817 回答