1
1
import {
2
+ AfterViewInit ,
2
3
Directive ,
3
4
DoCheck ,
4
5
ElementRef ,
8
9
OnChanges ,
9
10
OnDestroy ,
10
11
Output ,
12
+ Renderer2 ,
11
13
SimpleChanges
12
14
} from '@angular/core' ;
13
15
import { AnimationBuilder , AnimationPlayer , useAnimation } from '@angular/animations' ;
@@ -21,7 +23,7 @@ import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion';
21
23
selector : '[cCollapse]' ,
22
24
exportAs : 'cCollapse'
23
25
} )
24
- export class CollapseDirective implements OnChanges , OnDestroy , DoCheck {
26
+ export class CollapseDirective implements OnChanges , OnDestroy , DoCheck , AfterViewInit {
25
27
26
28
static ngAcceptInputType_navbar : BooleanInput ;
27
29
@@ -60,6 +62,7 @@ export class CollapseDirective implements OnChanges, OnDestroy, DoCheck {
60
62
get navbar ( ) {
61
63
return this . _navbar ;
62
64
}
65
+
63
66
/**
64
67
* @ignore
65
68
*/
@@ -79,9 +82,11 @@ export class CollapseDirective implements OnChanges, OnDestroy, DoCheck {
79
82
80
83
constructor (
81
84
private hostElement : ElementRef ,
85
+ private renderer : Renderer2 ,
82
86
private animationBuilder : AnimationBuilder
83
87
) {
84
88
this . host = this . hostElement . nativeElement ;
89
+ this . renderer . setStyle ( this . host , 'display' , 'none' ) ;
85
90
}
86
91
87
92
@HostBinding ( 'class' )
@@ -92,6 +97,10 @@ export class CollapseDirective implements OnChanges, OnDestroy, DoCheck {
92
97
} ;
93
98
}
94
99
100
+ ngAfterViewInit ( ) : void {
101
+ this . renderer . removeStyle ( this . host , 'display' ) ;
102
+ }
103
+
95
104
ngOnDestroy ( ) : void {
96
105
this . destroyPlayer ( ) ;
97
106
}
0 commit comments