问题
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