src/app/modules/telemetry/directives/telemetry-end/telemetry-end.directive.ts
OnDestroy
Selector | [appTelemetryEnd] |
Properties |
|
Methods |
Inputs |
HostListeners |
constructor(telemetryService: TelemetryService)
|
||||||||
Constructor to create injected service(s) object Default method of Draft Component class
Parameters :
|
appTelemetryEnd | |
Type : IEndEventInput
|
|
Interact event input |
window:unload |
Arguments : '$event'
|
endEvent |
endEvent()
|
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Returns :
void
|
unloadHandler | ||||
unloadHandler(event)
|
||||
Decorators :
@HostListener('window:unload', ['$event'])
|
||||
Parameters :
Returns :
void
|
Public telemetryService |
Type : TelemetryService
|
reference of permissionService service. |
import { Directive, Input, OnDestroy, HostListener } from '@angular/core';
import { IEndEventInput } from '../../interfaces';
import { TelemetryService } from '../../services';
@Directive({
selector: '[appTelemetryEnd]'
})
export class TelemetryEndDirective implements OnDestroy {
/**
* Interact event input
*/
@Input() appTelemetryEnd: IEndEventInput;
/**
* reference of permissionService service.
*/
public telemetryService: TelemetryService;
/**
* Constructor to create injected service(s) object
Default method of Draft Component class
* @param {TelemetryService} telemetryService Reference of TelemetryService
*/
constructor(telemetryService: TelemetryService) {
this.telemetryService = telemetryService;
}
@HostListener('window:unload', ['$event'])
unloadHandler(event) {
this.endEvent();
}
ngOnDestroy() {
this.endEvent();
}
endEvent () {
if (this.appTelemetryEnd) {
this.telemetryService.end(this.appTelemetryEnd);
}
}
}