2016-11-17 56 views
1

我想盡組合,我能想到的...角2現有的選擇是不是一個已知元素

我想添加一個所見即所得的編輯器轉變爲角2.

,但不管是什麼我做,我得到'編輯器不是已知元素'

它是進口的。它被宣佈。選擇器存在。

我完全難住了。

EditorComponent

import {NgModule, Component, ElementRef, AfterViewInit, Input, Output, EventEmitter, ContentChild, OnChanges, forwardRef} from '@angular/core'; 
    import {CommonModule} from '@angular/common'; 
    import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms'; 

    @Component({ 
     selector: 'header', 
     template: '<ng-content></ng-content>' 
    }) 
    export class Header { } 

    declare var Quill: any; 

    export const EDITOR_VALUE_ACCESSOR: any = { 
     provide: NG_VALUE_ACCESSOR, 
     useExisting: forwardRef(() => EditorComponent), 
     multi: true 
    }; 

    @Component({ 
     selector: 'editor', 
     templateUrl: "./editor.component.html", 
     providers: [EDITOR_VALUE_ACCESSOR] 
    }) 
    export class EditorComponent implements AfterViewInit, ControlValueAccessor { 
     ... 
     ... 
    } 

EditorModule

import { NgModule } from '@angular/core'; 
import { CommonModule } from "@angular/common"; 
import { ReactiveFormsModule } from "@angular/forms"; 
import { RouterModule } from '@angular/router'; 

import { EditorComponent } from "./editor.component"; 


const declarables = [EditorComponent]; 

@NgModule({ 
    imports: [CommonModule, ReactiveFormsModule, RouterModule], 
    exports: [declarables], 
    declarations: [declarables], 
}) 
export class EditorModule { } 

app.module

import { NgModule }    from '@angular/core'; 
import { BrowserModule }  from '@angular/platform-browser'; 
import { HttpModule }   from '@angular/http'; 
import { FormsModule }   from '@angular/forms'; 

import { AppComponent }   from './app.component'; 
import { routing, 
     appRoutingProviders } from './app.routing'; 


import { BlogModule }   from './blog/blog.module' 

import { LoginComponent }  from './user/login.component'; 
import { NavComponent }   from './nav/nav.component'; 

import { DialogService }  from './dialog.service'; 

import { CKEditorModule }  from 'ng2-ckeditor'; 

@NgModule({ 
    imports: [ 
    BrowserModule, 
    CKEditorModule, 
    HttpModule, 
    FormsModule, 
    routing, 
    BlogModule, 
    ], 
    declarations: [ 
    AppComponent, 
    LoginComponent, 
    NavComponent, 
    ], 
    providers: [ 
    appRoutingProviders, 
    DialogService 
    ], 
    bootstrap: [ AppComponent ], 

}) 
export class AppModule { 
} 

博客,edit.component

import { Component, OnInit, HostBinding, 
     trigger, transition, animate, 
     style, state } from '@angular/core'; 
import { Router, ActivatedRoute, Params } from '@angular/router'; 

import { BlogService } from './blog.service'; 

import { BlogPost } from '../model/blog-post'; 

import { EditorModule } from '../editor/editor.module' 

@Component({ 
    templateUrl: './blog-edit.component.html', 
    styleUrls: ['blog-edit.component.scss'], 
    animations: [ 
    trigger('routeAnimation', [ 
     state('*', 
     style({ 
      opacity: 1, 
      transform: 'translateX(0)', 
     }) 
    ), 
     transition('void => *', [ 
     style({ 
      opacity: 0, 
      transform: 'translateX(-100%)' 
     }), 
     animate('0.2s ease-in') 
     ]), 
     transition('* => void', [ 
     animate('0.5s ease-out', style({ 
      opacity: 0, 
      transform: 'translateY(100%)' 
     })) 
     ]) 
    ]) 
    ] 
}) 
export class BlogEditComponent implements OnInit { 
    ... 
    ... 
    ... 
} 

博客,edit.html

<editor></editor> 

回答

1
@NgModule({ 
    imports: [CommonModule, ReactiveFormsModule, RouterModule], 
    exports: [declarables], 
    declarations: [declarables], 
}) 

應該

@NgModule({ 
    imports: [CommonModule, ReactiveFormsModule, RouterModule], 
    exports: declarables, 
    declarations: declarables, 
}) 
+0

我很沮喪,只是移除了回購協議,我試圖用鵝毛筆編輯器的所有引用。除非你可能有關於如何包含PrimeNg編輯器的一些信息,我只是要刪除這個問題 – TheRealMrCrowley

+2

好吧,這是另一個問題,但基於我可以看到,你只是有一個語法問題,你不應該'把數組放在數組裏面,沒有意義。 – Milad

+0

我同意。我只是生氣了。我打賭你是對的,明天我會嘗試 – TheRealMrCrowley

相關問題