File tree Expand file tree Collapse file tree 2 files changed +7
-12
lines changed
components/accordion-list Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -10,21 +10,20 @@ export class AccordionListComponent {
10
10
@Input ( ) contentColor : string = '#F9F9F9' ;
11
11
@Input ( ) title : string ;
12
12
@Input ( ) hasMargin : boolean = true ;
13
- @Input ( ) initialState : string ;
14
- @Input ( ) expanded : boolean ;
13
+ @Input ( ) expanded : boolean ;
15
14
16
15
@ViewChild ( 'accordionContent' ) elementView : ElementRef ;
17
16
18
17
viewHeight : number ;
19
18
20
19
constructor ( public renderer : Renderer ) { }
21
-
20
+
22
21
ngAfterViewInit ( ) {
23
- this . handleInitialState ( ) ;
24
22
this . viewHeight = this . elementView . nativeElement . offsetHeight ;
25
- console . log ( this . expanded ) ;
26
- if ( ! this . expanded )
23
+
24
+ if ( ! this . expanded ) {
27
25
this . renderer . setElementStyle ( this . elementView . nativeElement , 'height' , 0 + 'px' ) ;
26
+ }
28
27
}
29
28
30
29
toggleAccordion ( ) {
@@ -33,8 +32,4 @@ export class AccordionListComponent {
33
32
this . renderer . setElementStyle ( this . elementView . nativeElement , 'height' , newHeight ) ;
34
33
}
35
34
36
- handleInitialState ( ) {
37
- this . expanded = this . initialState === 'expanded'
38
- }
39
-
40
35
}
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
17
headerColor ="#F53D3D "
18
- initialState =" expanded ">
18
+ [expanded] =" index === 0 ">
19
19
< img [src] ="item.imageUrl ">
20
20
< p text-wrap > {{item.description}}</ p >
21
21
</ accordion-list >
You can’t perform that action at this time.
0 commit comments