我有一个组件将输入发送到另一个组件。或者至少我是这么认为的。有人能帮我弄清楚错误吗?我跟着this page继续前进,似乎无法弄明白。
我得到的错误是:
Can't bind to 'item' since it isn't a known native property
这是我的相关父级TS和HTML(注意我为此帖子修剪了它):
import {Child} from'./child'
@Component({
...,
directives: [..., Child]
})
export class ParentMain {
}
<div class="container">
<child [item]="false"></child>
</div>
以下是相关的子TS和HTML:
import {Component, Input} from '@angular/core'
@Component({
...,
selector: "child"
})
export class Child {
@Input() public item: boolean;
}
<div *ngIf='item'>
<a href="#" >Test</a>
</div>