【问题标题】:Angular 2.0 Release: Pipes and Directives are not properties of @Component anymoreAngular 2.0 发布:管道和指令不再是 @Component 的属性
【发布时间】:2017-01-25 03:09:01
【问题描述】:

我刚刚将我在 RC5 上构建的应用升级到最终版本,我对现在应该声明指令和管道的方式感到困惑。我收到此错误:

[默认] C:\xampp\htdocs\meriem-car\public\src\app\components\administration.component.ts:12:4 中的错误 '{ moduleId: string; 类型的参数选择器:字符串;指令:typeof LoginComponent[];模板网址:字符串; }' 不可分配给“组件”类型的参数。 对象字面量只能指定已知属性,而“组件”类型中不存在“指令”。

【问题讨论】:

    标签: angular angular-directive angular-pipe


    【解决方案1】:

    自 RC6 起,所有指令和管道都应移至模块的 declarations

    @NgModule({
        imports: [...],
        declarations: [
            //you insert your Components, Directives and Pipes here
        ],
        bootstrap: [...],
        providers: [...]
    })
    
    export class AppModule { }
    

    【讨论】:

    • @ESturzenegger 您是否从组件中删除了directives
    • sry 删除我的问题:“即使将其添加到声明中,它也会显示相同的错误”@StefanSvrkota 是的,我做到了。有趣的是:管道有效,但错误显示在我的 cli 中。
    • @ESturzenegger 好吧,我真的不知道,请尝试重新启动/刷新您的项目。真的很奇怪。
    • @StefanSvrkota 根据文档是管道属性不存在:angular.io/docs/ts/latest/api/core/index/…
    猜你喜欢
    • 2017-06-17
    • 1970-01-01
    • 2017-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 2018-06-04
    相关资源
    最近更新 更多