Angular4中如何使用CKEditor?
How to use CKEditor in Angular 4?
- 我使用
npm install ng2-ckeditor
这个命令安装 CKEditor。
- 然后在我的
index.html
中添加ckeditor.js
- 然后在
app.module.ts
中导入import { CKEditorModule } from 'ng2-ckeditor';
然后在我的HTML页面使用CKEditor
<ckeditor ngModel="{{ckeditorContent}}" formControlName="circular_contents" [config]="{uiColor: '#99000'}" [readonly]="false" debounce="500" debounce="500">
</ckeditor>
当时我得到错误ERROR TypeError: Cannot set property 'dir' of undefined
现在如何在我的 HTML 页面中使用 CKEditor。
一切正常只是在您的 index.html 页面中包含 ckeditor cdn link,不要下载 ckeditor.js.
<script src="https://cdn.ckeditor.com/4.5.11/full/ckeditor.js"></script>
由于您正在使用 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>
- 我使用
npm install ng2-ckeditor
这个命令安装 CKEditor。 - 然后在我的
index.html
中添加 - 然后在
app.module.ts
中导入 然后在我的HTML页面使用CKEditor
<ckeditor ngModel="{{ckeditorContent}}" formControlName="circular_contents" [config]="{uiColor: '#99000'}" [readonly]="false" debounce="500" debounce="500"> </ckeditor>
当时我得到错误
ERROR TypeError: Cannot set property 'dir' of undefined
ckeditor.js
import { CKEditorModule } from 'ng2-ckeditor';
现在如何在我的 HTML 页面中使用 CKEditor。
一切正常只是在您的 index.html 页面中包含 ckeditor cdn link,不要下载 ckeditor.js.
<script src="https://cdn.ckeditor.com/4.5.11/full/ckeditor.js"></script>
由于您正在使用 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>