projects/i-components/src/lib/components/popup/directives/life-cycle.directive.ts
LifeCycle directive Used to trigger angular lifecycle methods as events
Selector | [wmLifeCycle] |
Properties |
Methods |
Outputs |
destroy | |
Type : EventEmitter
|
|
destroy event |
init | |
Type : EventEmitter
|
|
init event |
ngAfterViewInit |
ngAfterViewInit()
|
Execute init event
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Execute destroy event
Returns :
void
|
Readonly destroy |
Default value : new EventEmitter<void>()
|
Decorators :
@Output()
|
destroy event |
Readonly init |
Default value : new EventEmitter<void>()
|
Decorators :
@Output()
|
init event |
import {
AfterViewInit,
Directive,
EventEmitter,
OnDestroy,
Output,
} from '@angular/core';
/**
* LifeCycle directive
* Used to trigger angular lifecycle methods as events
*
* @export
* @class LifeCycleDirective
* @implements {AfterViewInit}
* @implements {OnDestroy}
*/
@Directive({
selector: '[wmLifeCycle]',
})
export class LifeCycleDirective implements AfterViewInit, OnDestroy {
/**
* init event
*
* @memberof LifeCycleDirective
*/
@Output()
readonly init = new EventEmitter<void>();
/**
* destroy event
*
* @memberof LifeCycleDirective
*/
@Output()
readonly destroy = new EventEmitter<void>();
/**
* Execute init event
*
* @memberof LifeCycleDirective
*/
ngAfterViewInit(): void {
this.init.emit();
}
/**
* Execute destroy event
*
* @memberof LifeCycleDirective
*/
ngOnDestroy(): void {
this.destroy.emit();
}
}