【发布时间】:2018-05-30 16:09:52
【问题描述】:
我有一个生成的子手风琴列表,每个子手风琴在父手风琴内使用 ngFor 生成的面板列表的一个面板内。我需要根据某些逻辑切换特定的子手风琴。但是它不起作用,我无法在 ngfor 生成的手风琴列表中识别出一个手风琴。
在html文件中
<ngb-accordion #acc1="ngbAccordion" >
<ngb-panel #parentPanel *ngFor="let parentPanel of parentPanels; let parentPanelIndex=index" id="{{parentPanelIndex}}">
<ngb-accordion #acc2="ngbAccordion" >
<ngb-panel *ngFor="let childPanel of ChildrenPanels; let childPanelIndex=index" id="{{childPanelIndex}}">
....
在ts文件中:
@ViewChildren('parentPanels') parentPanels: QueryList<NgbPanel>;
....
this.parentPanels.toArray()[this.parentPanelIndex]
最后一行将根据“parentPanelIndex”中存储的值给我一个特定面板的引用。现在我可以访问父面板,但我不知道如何在该面板中获取对手风琴 (acc2) 的引用。有什么建议吗?
【问题讨论】:
标签: javascript angular typescript ng-bootstrap