CKeditor组件,角度为4

Nit*_*tin 2 javascript ckeditor angular

我是Angular4的新手

我想在Angular4中集成CKeditor

当我按照这个 url但是Angular 2没有在Angular 4中工作.

因为我在那里检查

System.config({
"map": {
  "ng2-ckeditor": "npm:ng2-ckeditor",
},
"packages": {
  "ng2-ckeditor": {
    "main": "lib/index.js",
    "defaultExtension": "js",
  },
}
});
Run Code Online (Sandbox Code Playgroud)

但Angular 4中没有System.config的任何选项

然后我已经集成froala但它提供许可证错误,也不允许配置,我尝试但它没有影响

如何在Angular4中集成CKeditor?

luc*_*cas 5

我假设你angular-cli用来创建你的angular 4项目,你不需要system.config angular-clli,只在system.js中使用,你在那里的代码告诉system.js在哪里找到ckeditor模块.如果您不清楚,只需检查您的项目是否有'angular-cli.json'文件,如果有,那么您可以按照以下步骤操作:

  1. 用于npm install ng2-ckeditor安装ng2-ckeditor
  2. 在你的app.module.ts,你应该有这样的东西
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { CKEditorModule } from 'ng2-ckeditor';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],

  imports: [
    BrowserModule,
    CKEditorModule,
    FormsModule
  ],

  providers: [],

  bootstrap: [AppComponent]
})

export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

然后

  1. 在index.html中添加
<script src="https://cdn.ckeditor.com/4.5.11/full/ckeditor.js"></script>
Run Code Online (Sandbox Code Playgroud)

头部内侧.或者,您可以将js文件保存在项目中,然后输入.angular-cli.json文件,将该文件的文件添加到scripts数组中

那么你很高兴在角度4项目中使用ckeditor

  • @Nitin为了使用`ngModel`,你需要从`@angular/forms`导入`FormsModule`,我需要你更多的代码细节来识别第二个问题,或者你可以检查这个[repo](https: //github.com/lcshan/ngx-ckeditor-template),这是一个带角度4和ckeditor的工作模板 (2认同)