Angular 2.0 发布:管道和指令不再是@Component 的属性

编程入门 行业动态 更新时间:2024-10-26 13:23:27
本文介绍了Angular 2.0 发布:管道和指令不再是@Component 的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

I just upgraded my app which I built on RC5 to the final release, and I'm confused of the way I should be declaring Directives and Pipes now. I'm getting this error:

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

ERROR in [default] C:\xampp\htdocs\meriem-car\public\src\app\components\administrationponent.ts:12:4 Argument of type '{ moduleId: string; selector: string; directives: typeof LoginComponent[]; templateUrl: string; }' is not assignable to parameter of type 'Component'. Object literal may only specify known properties, and 'directives' does not exist in type 'Component'.

推荐答案

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

Since RC6, all Directives and Pipes should be moved to module's declarations.

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

export class AppModule { }

这篇关于Angular 2.0 发布:管道和指令不再是@Component 的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-22 11:49:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023076.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:指令   管道   属性   Angular   Component

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!