angular - 带有 angular2 angular cli 的 CKeditor 组件

标签 angular ckeditor angular-cli

我正在尝试使用 Angular2 运行 ckeditor。我正在使用 Angular 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 中:

从'ng2-ckeditor'导入{CKEditorModule};

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

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

Unexpected value 'CKEditorModule' imported by the module 'AppModule'

我不明白为什么?

最佳答案

我找到了解决这个问题的方法:

  1. 在您的 index.html 中,只需将其添加到标题 block 中:

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

  1. 通过 NPM 安装 ng2-ckeditor

    npm install ng2-ckeditor --save

  2. 在您的 app.component.ts 中添加:

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

  3. 像这样使用编辑器:

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

关于angular - 带有 angular2 angular cli 的 CKeditor 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40089616/

相关文章:

javascript - Firebase 存储连接到 Angular 应用

javascript - CKeditor 不使用 Meteor 渲染

angular - 找不到本地工作区文件 ('angular.json')。但是相同的代码在另一台计算机上工作

javascript - 在 Angular CLI 1.2.4 中导入 JS

angular - 在 Angular 2 项目中运行 ngserve 命令时出错

Angular:HttpRequest.clone() - params 和 setParams 有什么区别?

unit-testing - Angular 2 RC6 : 'pattern-list' is not a known element

Angular2路由到静态txt文件

tabs - CKEditor 从标题之间删除空格/制表符

javascript - 删除 CKEditor 4 中的注释