File
Implements
Index
Properties
|
|
Methods
|
|
Inputs
|
|
Outputs
|
|
showCard
|
Type : boolean
|
Default value : true
|
|
Outputs
actionEvent
|
Type : EventEmitter
|
|
Methods
toggleAccordion
|
toggleAccordion()
|
|
|
isListItemOpened
|
Type : boolean
|
Default value : false
|
|
import { Component, OnInit, Input, Output, EventEmitter,ViewChild } from '@angular/core';
@Component({
selector: 'app-accordion-list',
templateUrl: './accordion-list.component.html',
styleUrls: ['./accordion-list.component.scss'],
})
export class AccordionListComponent implements OnInit {
@Input() data: any;
@Input() title: any;
@Input() showCard :boolean = true;
@Output() actionEvent = new EventEmitter();
isListItemOpened : boolean = false;
constructor() { }
ngOnInit() { }
action(event) {
this.actionEvent.emit(event)
}
toggleAccordion(): void {
this.isListItemOpened = !this.isListItemOpened;
}
}
<ion-card class="sb-dt-card accordian-card">
<ion-card-header (click)="toggleAccordion()">
<ion-item lines="none">
<ion-label>{{title | translate}}</ion-label>
<ion-icon *ngIf="isListItemOpened" name="arrow-up-circle-outline" slot="end" color="primary"></ion-icon>
<ion-icon *ngIf="!isListItemOpened" name="arrow-down-circle-outline" slot="end" color="primary"></ion-icon>
</ion-item>
</ion-card-header>
<ion-card-content *ngIf="isListItemOpened" >
<div *ngIf="showCard">
<ion-card slot="content" *ngFor="let content of data">
<ion-item lines="none" (click)="action(content)">
<ion-label>{{content?.name}}</ion-label>
<ion-icon md="caret-forward-circle" ios="chevron-forward-circle" slot="end" color="primary"></ion-icon>
</ion-item>
</ion-card>
</div>
<div *ngIf="!showCard">
<div *ngFor="let content of data" class="ion-padding">
<p> > {{content?.name}} </p>
</div>
</div>
</ion-card-content>
</ion-card>
.accordian-card{
margin: 0 0 1rem !important;
ion-card-header{
padding:0px;
}
ion-card-content{
padding:0px;
}
ion-item{
--background: var(--app-white) !important;
ion-icon{
font-size: 1.875rem;
}
}
}
Legend
Html element with directive