Initialising quill as part of an Angular component

一世执手 提交于 2020-05-17 06:15:08

问题


I want to set up an Angular component with a Quill element in it as follows (I do not want to use ngx-qull as I have a requirement to customise the component further): https://plnkr.co/edit/FWnHxo7eQpVtrzRN?open=lib%2Fscript.js&preview (wherein, I can assign a custom toolbar to a single Quill element as per https://github.com/quilljs/quill/issues/633#issuecomment-307709326)

Angular component

import * as Quill from 'quill';

constructor(
  private elementRef: ElementRef
) {
}

export class TestComponent implements OnInit, {
  ngOnInit() {
     this.componentId = this.elementRef.nativeElement['id'];
     const quill = new Quill(`#editor-${this.componentId}`, {});
     console.log(quill);
  }
}

HTML

<div id="editor-{{  componentId }}">
  <p>Hello World!</p>
  <p>Some initial <strong>bold</strong> text</p>
  <p><br></p>
</div>

However I keep getting the following error:

quill Invalid Quill container #editor-features-L7Q6yY1n

How do I fix this?

来源:https://stackoverflow.com/questions/61667844/initialising-quill-as-part-of-an-angular-component

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