File

projects/i-components/src/lib/directives/clickactionparameter.directive.ts

Description

Angular Directive for the wmClickActionParameter

Implements

OnInit OnChanges

Metadata

Selector [wmClickActionParameter]

Index

Properties
Methods
Inputs

Constructor

constructor(elementRef: ElementRef)

Constructor.

Parameters :
Name Type Optional
elementRef ElementRef No

Inputs

model
Type : any

Model of the element using the directive

wmClickActionParameter
Type : string | BindingInfo

click action parameter property

Methods

ngOnChanges
ngOnChanges(changes: SimpleChanges)

Angular life-cycle hook

Parameters :
Name Type Optional Description
changes SimpleChanges No

Simple changes parameter

Returns : void
ngOnInit
ngOnInit()

Event Handler for when the ngOninit.

Returns : void
setDependencyValue
setDependencyValue()

Sets the value to the Dependency property

Returns : void

Properties

model
Type : any
Decorators :
@Input()

Model of the element using the directive

wmClickActionParameter
Type : string | BindingInfo
Decorators :
@Input()

click action parameter property

import {
  Directive,
  ElementRef,
  Input,
  OnChanges,
  OnInit,
  SimpleChanges,
} from '@angular/core';
import {
  FrameworkElement,
  clickActionParameterProperty,
  BindingInfo,
  setDependencyPropertyValue,
  BaseDirective,
} from '@mobilize/wms-framework';

/**
 * Angular Directive for the wmClickActionParameter
 *
 * @export
 * @class ClickActionParameterDirective
 */
@Directive({
  selector: '[wmClickActionParameter]',
})
export class ClickActionParameterDirective
  extends BaseDirective
  implements OnInit, OnChanges
{
  /**
   * click action parameter property
   *
   * @type {any}
   * @memberof ClickActionParameterDirective
   */
  @Input()
  wmClickActionParameter: string | BindingInfo;

  /**
   * Model of the element using the directive
   *
   * @type {any}
   * @memberof ClickActionParameterDirective
   */
  @Input()
  model: any;

  /**
   * Constructor.
   *
   * @memberof ClickActionDirective
   */
  constructor(private elementRef: ElementRef) {
    super();
  }

  /**
   * Angular life-cycle hook
   *
   * @param changes Simple changes parameter
   */
  ngOnChanges(changes: SimpleChanges): void {
    /* istanbul ignore else */
    if (
      changes.wmClickActionParameter &&
      !changes.wmClickActionParameter.isFirstChange()
    ) {
      this.setDependencyValue();
    }
  }

  /**
   * Event Handler for when the ngOninit.
   *
   * @memberof ClickActionParameterDirective
   */
  /* istanbul ignore next */
  ngOnInit(): void {
    this.loadModel(this.elementRef);
    this.setDependencyValue();
  }

  /**
   * Sets the value to the Dependency property
   *
   * @memberof ClickActionParameterDirective
   */
  setDependencyValue(): void {
    if (this.model instanceof FrameworkElement) {
      setDependencyPropertyValue(
        clickActionParameterProperty,
        this.wmClickActionParameter,
        this.model
      );
    }
  }
}

result-matching ""

    No results matching ""