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