ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 275.4k

I try to make left side menu Collapse as accordion in angula

May 29 2020 8:16 PM
I work on angular 7 app I try to make left side menu accordion Expandable and Collapse but it does not work.
For main menu I display Main Reports Category as:
  1. "let rep of allReportCategories" style="margin-top:2px;" class="page-sidebar-menu" data-keep-expanded="false" data-auto-scroll="true" data-slide-speed="200">  
  2. class="accordion">{{rep.reportCategory}}  
For display sub category reports I depend on CategoryID to join between category and sub Category:
  1. *ngFor="let subrep of reportsubCategory"  
  2. "subrep.reportCategoryID === rep.reportCategoryID" class="wrapper">  
  3. class="sideNav nav navbar">{{subrep.reportName}}  
CSS Accordion :
  1. .accordion {  
  2. background-color: #eee;  
  3. color: #444;  
  4. cursor: pointer;  
  5. padding: 18px;  
  6. width: 100%;  
  7. border: none;  
  8. text-align: left;  
  9. outline: none;  
  10. font-size: 15px;  
  11. transition: 0.4s;  
  12. }  
I work on Stackbliz already have data and Show Main Category and Sub Category but the issue i can't solve Issue of accordion.
  1. https://stackblitz.com/edit/create-1arrvm?file=app%2Fapp.component.html  
my bussiness logic for button as below :
 
I need to pass main category to function getreportbycategory but i dont know
  1. this._displayreport.GetreportByCategoryId(this.reportid).subscribe((data: any[]) => {  
  2. this.reportsubCategory = data;  
  3. });  
  4. toggleAccordian(event, index) {  
  5. var element = event.target;  
  6. element.classList.toggle("active");  
  7. this._displayreport.GetreportByCategoryId(index);  
  8. }  
also How to display them as accordion when open page .

Answers (1)