无法在组件之间共享ng2-ckeditor。 SharedModule

时间:2016-10-05 15:04:07

标签: angular angular2-modules

我正在尝试将ng2-ckeditor添加到测试项目中。为此,我将以下行添加到systemjs.config.js

        'ng2-ckeditor': 'npm:ng2-ckeditor/lib/CKEditor.js'

shared.module.ts

import { NgModule }            from "@angular/core";
import { CommonModule }        from "@angular/common";
import { FormsModule }         from "@angular/forms";
import { CKEditorModule }      from "ng2-ckeditor";

@NgModule({
imports: [
    CommonModule,
    FormsModule,
    CKEditorModule
],
exports: [
    CommonModule,
    FormsModule,
    CKEditorModule
]
})

app.module.ts

import { NgModule, ChangeDetectorRef }      from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { AppComponent }   from "./app.component";
import { TestModule } from "./test/test.module";

@NgModule({
imports: [BrowserModule, TestModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }

test.module.ts

import { NgModule }            from "@angular/core";
import { CommonModule }        from "@angular/common";

import { SharedModule }        from "../share/shared.module";
import { TestComponent }       from "./test.component";
import { ChildComponent } from "./child/child.component";

@NgModule({
imports: [SharedModule],
declarations: [TestComponent, ChildComponent],
exports: [TestComponent]
})
export class TestModule { }

但收到错误。

  

原始例外:CKEDITOR未定义

All code

1 个答案:

答案 0 :(得分:1)

<强> app.module.ts

type(instance)

<强> test.module.ts

@NgModule({
imports: [BrowserModule,SharedModule,TestModule],   //<<<<<<<-----here
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }