【发布时间】:2019-07-20 01:34:41
【问题描述】:
我有一个“几乎”从其他组件复制粘贴的组件。
我的第一个组件继承与输入一起工作,但不是第二个。
然后我得到一个错误提示
Can't bind to 'anInput' since it isn't a known property of 'my-copied-component'.
<my-copied-component
[anInput]="someInputValue" <--- ERROR
>
</my-copied-component>
<my-original-component
[anInput]="someInputValue" <--- Works fine
>
</my-original-component>
实现:
export class MyCopiedComponent extends MyComponentsBase implements OnInit {
基本实现:
export class MyComponentsBase implements OnInit {
@Input() public anInput: string;
我在构造函数中有 super()。
【问题讨论】:
-
我们能否看到更多来自
MyComponentsBase和MyCopiedComponent的代码?特别是它们上面的组件装饰。
标签: angular typescript inheritance extends