在您的 angular 或 angular-ionic 应用程序中安装这两个软件包。
npm install --save @ckeditor/ckeditor5-angular
npm install --save @ckeditor/ckeditor5-build-classic
然后导入模块app.module.ts,并在组件中使用。
import * as CKEditor from '@ckeditor/ckeditor5-build-classic';
@Component({
selector: 'app-editor',
template: '<ckeditor [editor]="editor" [data]="summary"></ckeditor>',
styleUrls: ['./edit-summary.component.scss']
})
export class EditorComponent {
summary: string = `<p>Lorem ipsum</p>`
public editor = CKEditor
constructor() {
}
}
如果没有找到 ckeditor,请阅读以下内容:
即你有组件summary.component,它在summary.module 中声明,那么有必要在summary.module 中导入CKEditorModule。
假设你有 summary.module.ts 喜欢:
import { CKEditorModule } from '@ckeditor/ckeditor5-angular';
@NgModule({
declarations: [
SummaryComponent
],
imports: [
CommonModule,
CKEditorModule,
],
exports: [
SummaryComponent
],
})
export class SummaryModule { }
然后在summary.component.ts中导入CKEditor
import * as CKEditor from '@ckeditor/ckeditor5-angular';
@Component({
selector: 'app-edit-summary',
template: '<ckeditor [editor]="editor" [data]="summary"></ckeditor>',
styleUrls: ['./edit-summary.component.scss']
})
export class EditSummaryComponent {
summary: string = `<p>Lorem ipsum</p>`
public editor = CKEditor
constructor() {
}
}