projects/i-components/src/lib/directives/clickaction.directive.ts
Angular Directive for the wmClickAction
Selector | [wmClickAction] |
Properties |
Methods |
Inputs |
constructor(elementRef: ElementRef)
|
||||||
Constructor.
Parameters :
|
model | |
Type : any
|
|
Model of the element using the directive |
wmClickAction | |
Type : any
|
|
wmClickAction property |
wmClickActionParameter | |
Type : any
|
|
Directive action parameter |
ngOnChanges | ||||||||
ngOnChanges(changes: SimpleChanges)
|
||||||||
Angular life-cycle hook
Parameters :
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Angular life cycle hook.
Returns :
void
|
ngOnInit |
ngOnInit()
|
Angular life cycle hook.
Returns :
void
|
setDependencyValue |
setDependencyValue()
|
Sets the value to the Dependency property
Returns :
void
|
model |
Type : any
|
Decorators :
@Input()
|
Model of the element using the directive |
wmClickAction |
Type : any
|
Decorators :
@Input()
|
wmClickAction property |
wmClickActionParameter |
Type : any
|
Decorators :
@Input()
|
Directive action parameter |
import {
Directive,
ElementRef,
Input,
OnChanges,
OnDestroy,
OnInit,
SimpleChanges,
} from '@angular/core';
import {
BaseDirective,
ButtonBaseModel,
clickActionProperty,
setDependencyPropertyValue,
} from '@mobilize/wms-framework';
/**
* Angular Directive for the wmClickAction
*
* @export
* @class ClickActionDirective
*/
@Directive({
selector: '[wmClickAction]',
})
export class ClickActionDirective
extends BaseDirective
implements OnInit, OnChanges, OnDestroy
{
/**
* wmClickAction property
*
* @type {any}
* @memberof ClickActionDirective
*/
@Input()
wmClickAction: any;
/**
* Model of the element using the directive
*
* @type {any}
* @memberof ClickActionDirective
*/
@Input()
model: any;
/**
* Directive action parameter
*
* @type {any}
* @memberof ClickActionDirective
*/
@Input()
wmClickActionParameter: 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();
}
}
/**
* Angular life cycle hook.
*
* @memberof ClickActionDirective
*/
ngOnInit(): void {
this.loadModel(this.elementRef);
this.setDependencyValue();
}
/**
* Angular life cycle hook.
*
* @memberof ClickActionDirective
*/
ngOnDestroy(): void {
this.model?.setValue(clickActionProperty, null);
}
/**
* Sets the value to the Dependency property
*
* @memberof ClickActionDirective
*/
setDependencyValue(): void {
if (this.wmClickAction && this.model instanceof ButtonBaseModel) {
setDependencyPropertyValue(
clickActionProperty,
this.wmClickAction,
this.model
);
}
}
}