选择新语言时,ngx 鹅毛笔占位符不会改变

问题描述 投票:0回答:2
angular placeholder quill ngx-quill
2个回答
2
投票

注意:到目前为止(7 个月后)您应该已经找到了解决方案。

但我认为您缺少的是在框中设置占位符。

<quill-editor [placeholder]="'Topic.new.quill-placeholder'|translate"...></quill-editor>

这应该可以解决上面的问题。


1
投票

动态更改 Quill 占位符提供的解决方案对我有用:

quill.root.dataset.placeholder = 'Your new placeholder';

在 Angular 中,你的鹅毛笔代码可能是这样的:

let editor = this.container.nativeElement.querySelector('#editor');
this.editor = new Quill(editor, {
              theme: 'snow',
              placeholder: this.placeholder
            });

你的占位符属性可能是这样的:

@Input()
get placeholder() {
   return this._placeholder;
}
set placeholder(plh) {
   this._placeholder = plh;
   this.stateChanges.next();
}
public _placeholder: string;

因此,您需要做的是在属性设置器中添加一些代码来更新占位符,如下所示:

set placeholder(plh) {
     this._placeholder = plh;
     this.stateChanges.next();    
     if (this.editor != null) {      
      this.editor.root.dataset.placeholder = this._placeholder;      
     }
  }
© www.soinside.com 2019 - 2024. All rights reserved.