Can directives in Angular2 capture Component onCreate and onDestroy events?

Can directives in Angular2 capture component onCreate and onDestroy events? Actually I am trying to create a generic slideup and slidedown directive, so that when a component having this directive is added to DOM it slides down and when removed from the DOM it slides up. I am able to apply slideDown on component creation but slideUp animation doesn’t work since the element is immediately removed from the DOM.

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

From the docs:

ngOnInit
Initialize the directive/component after Angular initializes the data-bound input properties.

and

ngOnDestroy
Cleanup just before Angular destroys the directive/component. Unsubscribe observables and detach event handlers to avoid memory leaks.

But there are others, like ngAfterContentInit, that might be more appropriate.