2016-10-17 44 views
3

我想与Angular2运行ckeditor。我正在使用Angular CLI,并且我有一个非常基本的工作应用程序。CKeditor组件与angular2角cli

我已安装this package使用npm install ng2-ckeditor。我已经把我的system.config.js文件正是按照他们的榜样,即:

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

,并以同样的方式我app.modules.ts它包括:

进口{} CKEditorModule从 'NG2-CKEditor的';

@NgModule({ 
    // ... 
    imports:  [ 
    CKEditorModule 
    ], 
    // ... 
}) 
export class AppModule { } 

运行ng buildng serve后,我得到我的控制台以下错误:

预期的值 'CKEditorModule' 由模块进口 '的AppModule'

我不明白为什么?

+0

这个答案是完全回答对角4 [点击这里](https://stackoverflow.com/a/44598775/6266192)。例如, –

回答

6

我发现了一种方法,这一问题:

  1. 在您的index.html只是在报头块添加此:

<script src="https://cdn.ckeditor.com/4.6.1/full/ckeditor.js"></script>

  • 通过NPM安装ng2-ckeditor

    npm install ng2-ckeditor --save

  • 在你app.component.ts补充一点:

    import { CKEditorComponent } from '../../../node_modules/ng2-ckeditor/src/ckeditor.component'; @NgModule({ declarations: [ CKEditorComponent ], exports: [ CKEditorComponent, ] })

  • 使用编辑器这样的:

    <ckeditor [(ngModel)]="myContent" debounce="500"></ckeditor>

  • +0

    +1。有没有办法添加需要修改config.js的外部插件?有问题的插件是[pbckcode] (https://github.com/prbaron/pbckcode)。 – shark1608