如何在CKEditor中使用ngfor和ngif指令

时间:2019-10-10 08:44:04

标签: angular ckeditor

我正在使用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>

0 个答案:

没有答案