Javascript 具有角度4的编辑组件
我是Angular4的新手 我想在Angular4中集成CKeditor 正如我遵循的url,但它是用于Angular 2的,不适用于Angular 4 因为我已经在那里检查过了Javascript 具有角度4的编辑组件,javascript,angular,ckeditor,Javascript,Angular,Ckeditor,我是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",
System.config({
"map": {
"ng2-ckeditor": "npm:ng2-ckeditor",
},
"packages": {
"ng2-ckeditor": {
"main": "lib/index.js",
"defaultExtension": "js",
},
}
});
但Angular 4中的System.config没有任何选项
然后我集成了,但它给许可证错误,也不允许配置,我尝试了,但它没有效果
如何将CKeditor集成到Angular4中?我假设您使用
angular cli
创建angular 4项目,您不需要angular clli
中的system.config,它只在system.js中使用,并且您那里的代码告诉system.js在哪里可以找到CKeditor模块。
如果您不清楚,只需检查您的项目是否有“angular cli.json”文件,如果有,则可以执行以下步骤:
npm安装ng2 ckeditor
安装ng2 ckeditorapp.module.ts
中,您应该有如下内容
头部内侧部分。或者,您可以将js文件保存在项目中,然后在de.angular cli.json
文件中,将该文件的文件添加到脚本
数组中
那么您可以在angular 4项目中使用ckeditor了您得到的错误是什么?最常见的情况是,如果它适合A2,适合A4,那么在哪里设置System.config?@Nitin我自己也尝试过,它成功了,你有什么错误?首先我得到了这个错误“无法绑定到'ngModel',因为它不是'ckeditor'的已知属性”,然后如果我从ckeditor中删除ngModel attr,那么我得到了“error TypeError:无法设置未定义的属性'dir'”为此,我无法获得solution@Nitin为了使用
ngModel
,您需要从@angular/forms
导入FormsModule
,我需要您代码的更多详细信息来识别第二个问题,或者您可以检查一下,这是一个使用angular 4和ckeditori的工作模板,在脚本标记中将脚本文件添加到agular cli文件中,因此未定义错误的目录即将出现,因此已得到解决感谢它对我有效,但有一个问题,因为我将ckeditor库保留在本地库中并使用它,然后它不工作,如果我使用live,则如果我保留本地文件,则它工作路径,然后再次它给了我dir错误,所以你知道吗?
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 { }
<script src="https://cdn.ckeditor.com/4.5.11/full/ckeditor.js"></script>