File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
components/accordion-list Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,20 @@ export class AccordionListComponent {
10
10
@Input ( ) contentColor : string = '#F9F9F9' ;
11
11
@Input ( ) title : string ;
12
12
@Input ( ) hasMargin : boolean = true ;
13
+ @Input ( ) expanded : boolean ;
13
14
14
15
@ViewChild ( 'accordionContent' ) elementView : ElementRef ;
15
16
16
- expanded : boolean = false ;
17
17
viewHeight : number ;
18
18
19
19
constructor ( public renderer : Renderer ) { }
20
20
21
21
ngAfterViewInit ( ) {
22
22
this . viewHeight = this . elementView . nativeElement . offsetHeight ;
23
- this . renderer . setElementStyle ( this . elementView . nativeElement , 'height' , 0 + 'px' ) ;
23
+
24
+ if ( ! this . expanded ) {
25
+ this . renderer . setElementStyle ( this . elementView . nativeElement , 'height' , 0 + 'px' ) ;
26
+ }
24
27
}
25
28
26
29
toggleAccordion ( ) {
Original file line number Diff line number Diff line change 10
10
< ion-content padding >
11
11
< p > Accordion list example - Best places to visit:</ p >
12
12
13
- < accordion-list *ngFor ="let item of items "
13
+ < accordion-list *ngFor ="let item of items; let index = index "
14
14
[title] ="item.name "
15
15
textColor ="#FFF "
16
16
hasMargin ="false "
17
- headerColor ="#F53D3D ">
17
+ headerColor ="#F53D3D "
18
+ [expanded] ="index === 0 ">
18
19
< img [src] ="item.imageUrl ">
19
20
< p text-wrap > {{item.description}}</ p >
20
21
</ accordion-list >
You can’t perform that action at this time.
0 commit comments