问题描述
限时送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:关键词]
发布评论