2
  1. npm install ng2-ckeditor我使用此命令安装 CKEditor 。
  2. 然后加入ckeditor.js我的index.html
  3. import { CKEditorModule } from 'ng2-ckeditor';然后导入app.module.ts
  4. 然后在我的 HTML 页面中使用 CKEditor

     <ckeditor ngModel="{{ckeditorContent}}" formControlName="circular_contents" [config]="{uiColor: '#99000'}" [readonly]="false" debounce="500" debounce="500">
     </ckeditor>
    
  5. 那时我得到错误ERROR TypeError: Cannot set property 'dir' of undefined

现在我如何在我的 HTML 页面中使用 CKEditor。

4

2 回答 2

4

一切正常,只需在 index.html 页面中包含ckeditor cdn 链接,不要下载 ckeditor.js。

<script src="https://cdn.ckeditor.com/4.5.11/full/ckeditor.js"></script>
于 2018-01-10T04:54:19.423 回答
1

由于您使用的是 Angular 4,因此请将 ngModel 的语法更改为 [(ngModel)]。

像这样:

<ckeditor [(ngModel)]="templateConversionDTO.htmlContent"
                name="myckeditor" required debounce="500"> </ckeditor>

并且不要忘记在您的 Index.html文件中添加Ckeditor 的 CDN,这很重要。

<script src="https://cdn.ckeditor.com/4.6.1/full/ckeditor.js"></script>
于 2018-11-16T09:06:40.880 回答