File

projects/k-components/src/lib/directives/clickaction.directive.ts

Metadata

Selector [clickAction]

Index

Properties
Methods
Inputs
HostListeners

Inputs

clickAction
Type : any
clickActionParameter
Type : any
model
Type : any

HostListeners

click
Arguments : '$event.target'

Methods

onClick
onClick(btn)
Decorators :
@HostListener('click', ['$event.target'])
Parameters :
Name Optional
btn No
Returns : void

Properties

clickAction
Type : any
Decorators :
@Input()
clickActionParameter
Type : any
Decorators :
@Input()
model
Type : any
Decorators :
@Input()
import { Directive, HostListener, Input } from '@angular/core';
import {
  clickActionParameterProperty,
  UIElement,
} from '@mobilize/wms-framework';

@Directive({
  selector: '[clickAction]',
})
export class ClickActionDirective {
  @Input()
  clickAction: any;
  @Input()
  model: any;
  @Input()
  clickActionParameter: any;

  @HostListener('click', ['$event.target'])
  onClick(btn) {
    let dependencyPropertyValue: string;
    if (this.model instanceof UIElement) {
      dependencyPropertyValue = this.model.getValue(
        clickActionParameterProperty
      );
    }
    if (this.clickAction?.Execute) {
      const parameter = this.clickActionParameter ?? dependencyPropertyValue;
      this.clickAction?.Execute(parameter);
    }
  }
}

result-matching ""

    No results matching ""