我现在有ngb-手风琴设置到许多面板。默认情况下,面板将关闭,当单击时,我将使用自定义函数展开面板。我想知道如何设置一个手风琴在默认情况下展开,如果类别名称是选择的。
<div class="col-md-12">
<ngb-accordion #filterAccordion [animation]="false" (click)="heightChanged()"#acc="ngbAccordion" [activeIds]="activeIds">
<ngb-panel *ngFor="let filterCategory of filterCategories | filterCategory | keyvalue : returnZero ;let i= index" id="panel-{{i}}">
<ng-template ngbPanelTitle>
<button class="header-btn" (click)="heightChanged()">
<span>{{filterCategory.value.translationId | translate}}</span>
</button>
</ng-template>
<ng-template ngbPanelContent *ngIf="filterCategory.value.filterParameters.length > 0">
<div class="row">
<div class=" col-md-2" *ngFor="let filter of filterCategory.value.filterParameters | keyvalue">
<app-filter-parameters *ngIf="filterCategory.key.toString() !== 'select'"
[(filterParameterValue)]="filter.value.value"
[filterParameterName]="filter.value.key"
[dsaComponent]="'dashboardFilter'"
(applyFilters)="apply()">
</app-filter-parameters>
</div>
</div>
<div class="row">
<div class="form-group col-md-2" *ngIf="filterCategory.key.toString() === 'select'">
<app-date-picker
[filterParameters]="filterCategory.value.filterParameters"
[dsaComponent]="'dashboardFilter'"
(updateTimeframe)="this.updateFilter($event)">
</app-date-picker>
</div>
</div>
</ng-template>
</ngb-panel>
</ngb-accordion>
</div>
发布于 2022-04-10 19:09:23
为所有ngb-面板设置相同的ID:
<ngb-accordion [activeIds]="activeIds"></ngb-accordion>
// For example
this.activeIds = ['UNIQ_ID','UNIQ_ID','UNIQ_ID'];
发布于 2022-04-10 19:30:35
您应该首先使用activeIds
打开面板。
您在每个面板中添加了id="panel-{{i}}"
。因此,例如,如果默认打开第一个面板,则应该初始化activeIds="panel-0"
<ngb-accordion #filterAccordion [animation]="false" (click)="heightChanged()"#acc="ngbAccordion" activeIds="panel-0">
https://stackoverflow.com/questions/71819469
复制相似问题