projects/k-components/src/lib/directives/clickaction.directive.ts
Selector | [clickAction] |
Properties |
Methods |
Inputs |
HostListeners |
clickAction | |
Type : any
|
|
clickActionParameter | |
Type : any
|
|
model | |
Type : any
|
|
click |
Arguments : '$event.target'
|
onClick | ||||
onClick(btn)
|
||||
Decorators :
@HostListener('click', ['$event.target'])
|
||||
Parameters :
Returns :
void
|
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);
}
}
}