File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
components/accordion-list Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,21 @@ 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
15
14
16
@ViewChild ( 'accordionContent' ) elementView : ElementRef ;
15
17
16
- expanded : boolean = false ;
17
18
viewHeight : number ;
18
19
19
20
constructor ( public renderer : Renderer ) { }
20
-
21
+
21
22
ngAfterViewInit ( ) {
23
+ this . handleInitialState ( ) ;
22
24
this . viewHeight = this . elementView . nativeElement . offsetHeight ;
23
- this . renderer . setElementStyle ( this . elementView . nativeElement , 'height' , 0 + 'px' ) ;
25
+ console . log ( this . expanded ) ;
26
+ if ( ! this . expanded )
27
+ this . renderer . setElementStyle ( this . elementView . nativeElement , 'height' , 0 + 'px' ) ;
24
28
}
25
29
26
30
toggleAccordion ( ) {
@@ -29,4 +33,8 @@ export class AccordionListComponent {
29
33
this . renderer . setElementStyle ( this . elementView . nativeElement , 'height' , newHeight ) ;
30
34
}
31
35
36
+ handleInitialState ( ) {
37
+ this . expanded = this . initialState === 'expanded'
38
+ }
39
+
32
40
}
Original file line number Diff line number Diff line change 14
14
[title] ="item.name "
15
15
textColor ="#FFF "
16
16
hasMargin ="false "
17
- headerColor ="#F53D3D ">
17
+ headerColor ="#F53D3D "
18
+ initialState ="expanded ">
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