Posts

Showing posts with the label toggle

How to use ngFor for an accordion to loop multiple times in Angular

How to use ngFor for an accordion to loop multiple times in Angular I have the below code for creating accordion using plus and minus icons. I have handled the toggle functionality as well. But now I want to loop this inside ngFor for multiple set of elements . I am not sure how to do this. Basically i have a resultArray which is a json . I need to loop through resultArray json to get the heading and description and place it as accordion heading and accordion description. I am not sure how to replace the accord.id dynamically. <div *ngFor = "let resulArray of resultArray"> <div *ngFor="let accord of accordian;"> <div (click)="toggle(accord.id)" id="accordionTitle{{accord.id}}" class="accordionTitle active">{{accord.label}} <i class="fa fa-minus" id="minus{{accord.id}}"></i> </div> <div id="{{acco...