我有以下代码
<div class="data-container" #dataContainer>
<result (click)="onContainerClick($event, i)" *ngFor="let result of resultItems; let i = index" [result]="result" [index]="i"></result>
每个结果都有一个参数 关闭:布尔值;
如何从TS代码中的父级访问?
谢谢,
答案 0 :(得分:0)
.
.
.
import { ViewChildren, QueryList, AfterViewInit } from @angular/core
.
.
.
export class ParentComponent implements AfterViewInit {
@ViewChildren(ResultComponent) resultComps: QueryList<ResultComponent>;
ngAfterViewInit() {
this.resultComponents.forEach((comp: ResultComponent) => console.log(comp.closed));
}
}