【发布时间】:2017-03-29 08:28:03
【问题描述】:
我正在尝试为编辑器实现最大长度。我的代码是这样的:
this.editorTextChange$$ = this.quillEditor.onTextChange.asObservable()
.subscribe((ev) => {
const limit = this.maxLength;
// last char is \n, so don't count it
if (ev.textValue.length > limit) {
this.quillEditor.quill.deleteText(limit, ev.textValue.length);
}
// last char is \n, so don't count it
this.currentLength = this.quillEditor.quill.getLength() - 1;
});
<p-editor
#quill
[(ngModel)] = htmlValue>
<p-header>
<span>
<button title="Bold" class = "ql-bold"></button>
<button title="Italic" class = "ql-italic"></button>
<button title="Underline" class = "ql-underline"></button>
<button title="Link" class = "ql-link"></button>
</span>
</p-header>
</p-editor>
问题是编辑器在视图上得到更新,但模型保持不变。
如何更新?
谢谢!
【问题讨论】:
-
我们最终决定在更新产品规格后该功能将无用,但我仍然认为这对于想要从控制器更新文本的人来说可能很重要