tinymceの新機能で、setContent(this.content)メソッドを実際に配置する場所が不明です。私の現在のバージョンでは、私はエラーを取得するために引き起こしている:TinyMCE&Angular 2:@Inputに基づいてエディタのコンテンツを設定する
TypeError: null is not an object (evaluating 'body.nodeName') --- runTask — zone.js:170
ペルソナオブジェクトが正しく動作している私のデータベースを、照会サービスを介して取得されます。
<app-tinymce
[elementId]="'persona-footnotes'"
(onEditorContentChange)="keyupHandler($event)"
[content]="persona.footnotes"
></app-tinymce>
アプリ-tinymce.component.ts:
私は私のインスタンスは、私のpersona.component.htmlで、この1のように設定している。この考え方
import {
Component,
AfterViewInit,
EventEmitter,
OnDestroy,
Input,
Output
} from '@angular/core';
import 'tinymce';
import 'tinymce/themes/modern';
import 'tinymce/plugins/table';
import 'tinymce/plugins/link';
import 'tinymce/plugins/paste';
import 'tinymce/plugins/lists';
import 'tinymce/plugins/advlist';
import 'tinymce/plugins/code';
declare let tinymce: any;
@Component({
selector: 'app-tinymce',
templateUrl: './tinymce.component.html',
styleUrls: ['./tinymce.component.scss']
})
export class TinymceComponent implements AfterViewInit, OnDestroy {
@Input() elementId: String;
@Input() content: String;
@Output() onEditorContentChange = new EventEmitter();
editor;
ngAfterViewInit() {
tinymce.init({
selector: '#' + this.elementId,
plugins: ['link', 'table', 'lists', 'advlist', 'code'],
skin_url: '/assets/tinymce/skins/lightgray',
toolbar: [
'bold italic underline strikethrough subscript superscript removeformat | formatselect | fontsizeselect | bullist numlist outdent indent | link table | code'
],
menubar:'edit',
theme:'modern',
height:'300',
setup: editor => {
editor.setContent(this.content);
console.log(this.content); // this part outputs the correct data
this.editor = editor;
editor.on('keyup change',() => {
const content = editor.getContent();
this.onEditorContentChange.emit(content);
});
}
});
}
ngOnDestroy() {
tinymce.remove(this.editor);
}
}
は、の問題ですどこで/いつ "setContent(this.content)"メソッドを置くのですか?
ありがとう!これでエラーは解消されましたが、データが断続的に正常に表示されました。私はまた、* ngIf = "content.property"を追加しました。時間の100%を表示しました。(私の開発システムは、ここやそこの応答時間に少し欲しくなりました) – Eric