我使用的是垫-手风琴,里面有多个垫-扩展面板。在第一个mat-expansion面板上,我调用了一个函数(closed)。默认情况下,第一个mat-expansion-panel是closed.Now,当页面加载时,我点击第二个mat-expansion-panel,然后调用第一个mat-expansion-panel (关闭)的函数(它不应该是关闭的,因为它还没有打开)。
我希望当我们打开一个扩展面板,然后关闭它,或者打开任何其他扩展面板时,只有第一个扩展面板的(closed)函数将进入调用。
<mat-accordion class="example-headers-align myaccordion">
<mat-expansion-panel hideToggle="true" class="myexpension" (opened)="fetchGeneralInfo()" (closed)="collpaseClose(0)" #generalInfo>
<mat-expansion-panel-header>
<mat-panel-title>
General Information
</mat-panel-title>
</mat-expansion-panel>
<mat-expansion-panel hideToggle="true" class="myexpension" #guaInfo (opened)="fetchGua()" >
<mat-expansion-panel-header>
<mat-panel-title>
Gurantor Information
</mat-panel-title>
</mat-expansion-panel>发布于 2018-02-23 01:33:21
mat-accordion组件有一个输入属性multi。@Input()multi: boolean :折叠是否应该同时允许多个展开的折叠项。由于未设置为true,因此可能会触发其他扩展面板的关闭事件。将multi设置为true <mat-accordion [multi]="true">并选中。
发布于 2021-06-24 22:48:30
回答得很晚,但我遇到了同样的问题。
使用(afterExpand)=...而不是(opened)=...。
https://stackoverflow.com/questions/48425624
复制相似问题