11import {
2+ AfterViewInit ,
23 Directive ,
34 DoCheck ,
45 ElementRef ,
89 OnChanges ,
910 OnDestroy ,
1011 Output ,
12+ Renderer2 ,
1113 SimpleChanges
1214} from '@angular/core' ;
1315import { AnimationBuilder , AnimationPlayer , useAnimation } from '@angular/animations' ;
@@ -21,7 +23,7 @@ import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion';
2123 selector : '[cCollapse]' ,
2224 exportAs : 'cCollapse'
2325} )
24- export class CollapseDirective implements OnChanges , OnDestroy , DoCheck {
26+ export class CollapseDirective implements OnChanges , OnDestroy , DoCheck , AfterViewInit {
2527
2628 static ngAcceptInputType_navbar : BooleanInput ;
2729
@@ -60,6 +62,7 @@ export class CollapseDirective implements OnChanges, OnDestroy, DoCheck {
6062 get navbar ( ) {
6163 return this . _navbar ;
6264 }
65+
6366 /**
6467 * @ignore
6568 */
@@ -79,9 +82,11 @@ export class CollapseDirective implements OnChanges, OnDestroy, DoCheck {
7982
8083 constructor (
8184 private hostElement : ElementRef ,
85+ private renderer : Renderer2 ,
8286 private animationBuilder : AnimationBuilder
8387 ) {
8488 this . host = this . hostElement . nativeElement ;
89+ this . renderer . setStyle ( this . host , 'display' , 'none' ) ;
8590 }
8691
8792 @HostBinding ( 'class' )
@@ -92,6 +97,10 @@ export class CollapseDirective implements OnChanges, OnDestroy, DoCheck {
9297 } ;
9398 }
9499
100+ ngAfterViewInit ( ) : void {
101+ this . renderer . removeStyle ( this . host , 'display' ) ;
102+ }
103+
95104 ngOnDestroy ( ) : void {
96105 this . destroyPlayer ( ) ;
97106 }
0 commit comments