Angular 2现有选择器不是已知元素
我试过我能想到的每一种组合 我想在Angular 2中添加一个WYSIWYG编辑器 但无论我做什么,我都会得到“编辑器不是已知元素” 它是进口的。这是宣布的。选择器存在 我完全被难住了 编辑组件Angular 2现有选择器不是已知元素,angular,Angular,我试过我能想到的每一种组合 我想在Angular 2中添加一个WYSIWYG编辑器 但无论我做什么,我都会得到“编辑器不是已知元素” 它是进口的。这是宣布的。选择器存在 我完全被难住了 编辑组件 import {NgModule, Component, ElementRef, AfterViewInit, Input, Output, EventEmitter, ContentChild, OnChanges, forwardRef} from '@angular/core';
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 {
...
...
}
应用程序模块
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 {
}
blog-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 {
...
...
...
}
blog-edit.html
<editor></editor>
应该是
@NgModule({
imports: [CommonModule, ReactiveFormsModule, RouterModule],
exports: declarables,
declarations: declarables,
})
我很沮丧,只是从我试图使用的repo中删除了所有关于羽毛笔编辑器的引用。除非你有一些关于如何包含priming编辑器的信息,否则我将删除这个问题好吧,这是另一个问题,但根据我所看到的,你只是有一个语法问题,你不应该把数组放在数组中,没有意义。我同意。我只是生气了。我敢打赌你是对的,我明天会尝试它。具体是一个单独的问题,但是你能对未捕获的错误做出可能的解释吗:模块“AppModule”导入的意外值“CKEditorModule”?我在你的代码中看不到CKEditorModule,你能更新你的代码吗?
@NgModule({
imports: [CommonModule, ReactiveFormsModule, RouterModule],
exports: [declarables],
declarations: [declarables],
})
@NgModule({
imports: [CommonModule, ReactiveFormsModule, RouterModule],
exports: declarables,
declarations: declarables,
})