【发布时间】:2020-08-05 08:23:40
【问题描述】:
如何在 PrimeNG 中强制不打开手风琴。我的意思是在某些情况下,我不希望我选择的手风琴打开。这种方式我试过了,但是不行
https://www.primefaces.org/primeng/showcase/#/accordion
<p-accordion #accordionQuestion *ngIf="questionItems && questionItems.length > 0"
[activeIndex]="currentIndexAccordion"
class="text-left mt-2 w-100"
(onOpen)="checkOpenAccordion($event)"
[expandIcon]="'fa fa-fw fa-chevron-right'"
[collapseIcon]="'fa fa-fw fa-chevron-down'">
<p-accordionTab #accordionTab *ngFor="let question of questionItems; let i = index;"
class="mb-2" id="accordionTab">
<p-header class="w-100">
<span class="w-100" [innerText]="question.code + ' - ' + question.text"></span>
</p-header>
<question #question *ngIf="i == currentIndexAccordion"
(formValuesChanged)="questionChanged($event)"
</question>
</p-accordionTab>
</p-accordion>
checkOpenAccordion方法在哪里
@ViewChild('question', {static: false}) accordion: Accordion;
checkOpenAccordion(index: number) {
if (this.currentIndexAccordion != index && this.changed) {
this.disabledOthersAccordion();
this.accordionQuestion.activeIndex = this.currentIndexAccordion;
} else {
this.currentIndexAccordion = index;
}
}
disabledOthersAccordion() {
if (this.accordion && this.accordion.tabs &&
this.accordionDomande.tabs.length > 0) {
for (let i = 0; i < this.accordion.tabs.length; i++) {
if (i !== this.currentIndexAccordion) {
this.accordion.tabs[i].disabled = true;
}
}
}
}
questionChanged(changed) {
this.changed = changed;
}
【问题讨论】:
-
你能创建 stackblitz 吗?
-
很遗憾没有
-
你想要什么
-
我有一些手风琴......每个手风琴都有一个表格。如果我将某些内容更改为表单(所以何时更改)如果我尝试单击另一个手风琴,我想停止或阻止打开新的手风琴点击并留在我当前的手风琴中。
-
你能做一个stackblitz吗here