[英]Angular 8 accordion with Dynamic data without using bootstrap/angular material
我試圖在不使用引導程序/角度材料手風琴的情況下實現手風琴功能。 我的數據來自api。
我嘗試在下面進行操作,但這會同時打開和關閉所有面板。 我了解背后的原因,但不了解如何處理。
Component.ts
export class AccordionComponent implements OnInit {
isHidden = true;
mFaqs: IFaq[];
constructor(private faqService: FaqService) { }
ngOnInit() {
this.faqService.getFaqs()
.subscribe(faqData => this.mFaqs = faqData );
}
}
component.html
<div class="custom-header" hideToggle="true" (click)="isHidden = !isHidden" *ngFor="let faq of mFaqs?.faqs">
<section>
<section>
Q: {{ faq.question }}
</section>
<p [hidden]="isHidden">
{{ faq.answer }}
</p>
</section>
</div>
它應該只關閉/打開被點擊的那個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.