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에서 이와 같은 설정이이 생각
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);
}
}
는의 문제입니다 where/"when"setContent (this.content) 메소드를 넣을 수 있지만 어디서 확실하지 않은가?
감사합니다! 오류를 없앴으나 표시되는 데이터에 대해 간헐적 인 성공을 거두었습니다. 나는 또한 * ngIf = "content.property"를 추가했고 시간의 100 %를 표시했다. (내 dev 시스템은 응답 시간에 여기저기서 조금씩 떠난다.) – Eric