你如何属性绑定子组件?我想让我的变量high
通过false or !this.high
它的父组件,但问题是,孩子正在循环
应用产品
<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;
}
这就是育儿的顺序。最上层是父母到它的孩子