我正在使用ng2-ckeditor动态显示数据,并且可以正常工作,但是当我使用ngFor和ngIf之类的指令时,它无法提供正确的输出。我阅读了ckeditor文档,但没有任何想法。 示例:我必须使用ckeditor显示一个表。
在.ts文件中:
policies = [
{id: 0, name: "policy001"},
{id: 2, name: "policy002"},
{id: 3, name: "policy003"},
{id: 4, name: "policy004"},
{id: 5, name: "policy005"},
];
this.mycontent = `
<table>
<thead>
<th># Policy ID</th>
<th>Policy name</th>
</thead>
<tbody>
<tr *ngFor="let policy of policies">
<td>{{policy.id}}</td>
<td>{{policy.name}}</td>
</tr>
</tbody>
</table>
`;
this.ckeConfig = {
allowedContent: true,
forcePasteAsPlainText: true
};
}
在HTML中:
<ckeditor [(ngModel)]="mycontent"
#myckeditor="ngModel"
name="myckeditor"
required
[config]="ckeConfig"
debounce="500"
(paste)="onPaste($event)"
(change)="onChange($event)">
</ckeditor>
</form>