File

projects/i-components/src/lib/components/popup/directives/life-cycle.directive.ts

Description

LifeCycle directive Used to trigger angular lifecycle methods as events

Implements

AfterViewInit OnDestroy

Metadata

Selector [wmLifeCycle]

Index

Properties
Methods
Outputs

Outputs

destroy
Type : EventEmitter

destroy event

init
Type : EventEmitter

init event

Methods

ngAfterViewInit
ngAfterViewInit()

Execute init event

Returns : void
ngOnDestroy
ngOnDestroy()

Execute destroy event

Returns : void

Properties

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();
  }
}

result-matching ""

    No results matching ""