0
你如何绑定一个子组件?我要让我的变量high
到false or !this.high
通过其父组件,但事实是,孩子被循环角2:父子组件属性绑定
应用产品
<button class="ui primary small button"(click)="clearVals()">Clear Selected</button>
<app-product-list [dataSource]="data"></app-product-list>
@ViewChild(ProductListComponent) prodList: ProductListComponent;
clearVals() {
this.selectedOutsourced = this.selectedPrice = 0;
this.prodList.clear();
this.selectedArray = [];
}
应用产品列表
<div class="products-cards" *ngFor="let product of dataSource['docs']">
<app-product-card [product]="product"(highlightEvent)="highlight($event)">
</app-product-card>
</div>
@ViewChild(ProductCardComponent) prodCard: ProductCardComponent;
应用产品卡片
<div class="list card ui" (click)="highlight()" [class.selected]="high"> </div>
high : boolean = false;
highlight(){
this.high = !this.high;
}
这是父母的顺序。最上面的是父母向其子女
什么是“孩子绕环”即使是什么意思? – Carsten
你是否试图将事件从小孩传播给父母? –
* ngFor @Carsten – Char