从构造函数中删除注入 - "请添加@ Pipe / @ Directive / @ Component注释。"

时间:2018-05-03 10:59:06

标签: angular

我已经阅读了我在这里找到的所有其他问题,但没有任何帮助我(

我有一个混合应用

"@angular/common": "4.4.6",
"@angular/compiler": "4.4.6",
"@angular/core": "4.4.6",
"@angular/router": "4.4.6",
"@angular/upgrade": "4.4.6",
"angular": "1.5.8",

一切正常,但我突然添加了新组件和模块

模块:

import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {KekComponent} from './kek.component';

@NgModule({
    imports: [
        CommonModule,
    ],
    exports: [KekComponent
    ],
    declarations: [
        KekComponent
    ],
    providers: []
})
export class KekModule {
}

成分:

import {Component} from '@angular/core';

@Component({
    selector: 'kek',
    template: 'div'
})
export class KekComponent {

    constructor() {
    }
}

我收到此错误Unexpected value 'KekComponent' declared by the module 'KekModule'. Please add a @Pipe/@Directive/@Component annotation.

没有错误类型(代码被复制),没有别的。 我应该在哪里寻找解决方案?

1 个答案:

答案 0 :(得分:0)

原来我已经有了这样的代码

import {NgModule, forwardRef} from '@angular/core';
import {KekModule} from './kek.module.ts';
import {UpgradeAdapter} from '@angular/upgrade';

并且解决方案是更改它们的顺序

import {NgModule, forwardRef} from '@angular/core';
import {UpgradeAdapter} from '@angular/upgrade';
import {KekModule} from './kek.module.ts';

facepalm混合应用