Quill Editor : Check for change in content in Angular?

落花浮王杯 提交于 2020-12-15 05:24:17

问题


I have implemented quill editor in Angular by creating new instance of quill and creating custom toolbar.

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

I have a "update" button which would call the update API. I need to check if the contents of the Quill editor has changed. I am aware of 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.');
        }
    });

However, I am not sure where do I place this? NgOnInit? NgAfterViewInit? I have created the quill instance in ngAfterViewInit. I know this could be a dumb question.

Any help appreciated! thanks! :)


回答1:


You can put it in the constructor of the module/component.



来源:https://stackoverflow.com/questions/63135622/quill-editor-check-for-change-in-content-in-angular

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!