我有一个使用 ngx-editor 的简单组件。html文件如下:
<ng-container>
<ngx-editor
class="ngxEditor-view"
[editor]="editorSummary"
[ngModel]="test"
[disabled]="true"
[placeholder]="'No description available...'"
></ngx-editor>
</ng-container>
ts 类:
import {Component, Input, OnInit, OnChanges, EventEmitter, Output, OnDestroy} from '@angular/core';
import {UntilDestroy} from '@ngneat/until-destroy';
import { Editor, Toolbar, Validators as EditorValidators } from 'ngx-editor';
@UntilDestroy({checkProperties: true})
@Component({
selector: 'app-test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.css']
})
export class TestComponent implements OnInit, OnChanges, OnDestroy {
editorSummary: Editor;
test: string="123";
constructor() {
}
ngOnInit() {
this.editorSummary = new Editor();
}
ngOnChanges(): void {
}
closeMe(): void {
this.isModalOpen = false;
this.closeModal.emit();
}
ngOnDestroy(): void {
this.editorSummary.destroy();
}
}
编辑器导入如下:
import { NgxEditorModule } from 'ngx-editor';
@NgModule({
imports: [
NgxEditorModule
],
永远不会显示文本,而是显示占位符的消息。可能是什么原因?我在应用程序的几个地方使用它。只有一页不起作用。