src/lib/components/hyperlink/hyperlink.component.ts
Angular Component for the Hyperlink Control.
ControlComponent
selector | wm-hyperlink |
styleUrls | ./hyperlink.component.scss |
templateUrl | ./hyperlink.component.html |
Properties |
|
Methods |
Inputs |
Outputs |
Accessors |
constructor(refChange: ChangeDetectorRef, render2: Renderer2, elem: ElementRef, webComponents: WebComponentsService, bringTopServ1: BringTopService)
|
||||||||||||||||||
Creates an instance of HyperlinkComponent.
Parameters :
|
cssClass | |
Type : string
|
|
Gets/sets the cssClass property. |
enabled | |
Type : boolean
|
|
Gets/sets the enabled property. |
navigateUrl | |
Type : string
|
|
Gets/sets the navigateUrl property. |
text | |
Type : string
|
|
Gets/sets the text property. |
NavigateToUrl | |
Type : EventEmitter<EventData>
|
|
NavigateToUrl event emitter. |
clickHandler | ||||||
clickHandler(event: any)
|
||||||
Handler for the click.
Parameters :
Returns :
void
|
getAttributesObject |
getAttributesObject()
|
Returns the attributes object from the model.
Returns :
any
{*} |
getClasses |
getClasses()
|
Returns the css classes to be applied.
Returns :
string
{string} |
triggerNavigateToPage | ||||||
triggerNavigateToPage(event: any)
|
||||||
Decorators :
@serverEvent('NavigateToUrl')
|
||||||
Triggers the NavigateToUrl emitter.
Parameters :
Returns :
void
|
Private cssClassInternal |
Type : string
|
Default value : ''
|
Property to save the cssClass value. |
Private enabledInternal |
Default value : true
|
Property to save the enabled value. |
Private navigateUrlInternal |
Type : string
|
Default value : ''
|
Property to save the navigateUrl value. |
Private textInternal |
Type : string
|
Default value : ''
|
Property to save the text value. |
text | ||||||
gettext()
|
||||||
settext(value: string)
|
||||||
Gets/sets the text property.
Parameters :
Returns :
void
|
navigateUrl | ||||||
getnavigateUrl()
|
||||||
setnavigateUrl(value: string)
|
||||||
Gets/sets the navigateUrl property.
Parameters :
Returns :
void
|
enabled | ||||||
getenabled()
|
||||||
setenabled(value: boolean)
|
||||||
Gets/sets the enabled property.
Parameters :
Returns :
void
|
cssClass | ||||||
getcssClass()
|
||||||
setcssClass(value: string)
|
||||||
Gets/sets the cssClass property.
Parameters :
Returns :
void
|
visible |
getvisible()
|
Gets the visible property.
Returns :
boolean
|
import {
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
Output,
Optional,
Renderer2,
Input
} from '@angular/core';
import {
ControlComponent,
WebComponentsService
} from '@mobilize/winforms-components';
import {
dataTransfer,
BringTopService,
EventData,
serverEvent
} from '@mobilize/base-components';
import { ErrorCodes, ExceptionHandlerClass } from '@mobilize/webmap-core';
/**
* Angular Component for the Hyperlink Control.
*
* @export
* @class HyperlinkComponent
* @extends {ControlComponent}
*/
@Component({
selector: 'wm-hyperlink',
templateUrl: './hyperlink.component.html',
styleUrls: ['./hyperlink.component.scss'],
inputs: ['model']
})
@dataTransfer(['hyprlnk'])
@ExceptionHandlerClass(ErrorCodes.Winforms)
export class HyperlinkComponent extends ControlComponent {
/**
* Property to save the text value.
*
* @private
* @memberof HyperlinkComponent
*/
private textInternal = '';
/**
* Property to save the navigateUrl value.
*
* @private
* @memberof HyperlinkComponent
*/
private navigateUrlInternal = '';
/**
* Property to save the enabled value.
*
* @private
* @memberof HyperlinkComponent
*/
private enabledInternal = true;
/**
* Property to save the cssClass value.
*
* @private
* @memberof HyperlinkComponent
*/
private cssClassInternal = '';
/**
* NavigateToUrl event emitter.
*
* @type {EventEmitter<EventData>}
* @memberof HyperlinkComponent
*/
@Output()
NavigateToUrl: EventEmitter<EventData> = new EventEmitter<EventData>();
/**
* Creates an instance of HyperlinkComponent.
*
* @param {ChangeDetectorRef} refChange
* @param {Renderer2} render2
* @param {ElementRef} elem
* @param {WebComponentsService} webComponents
* @param {BringTopService} bringTopServ1
* @memberof HyperlinkComponent
*/
constructor(
private refChange: ChangeDetectorRef,
private render2: Renderer2,
private elem: ElementRef,
webComponents: WebComponentsService,
@Optional() private bringTopServ1: BringTopService
) {
super(refChange, render2, elem, webComponents, bringTopServ1);
}
/**
* Gets/sets the text property.
*
* @memberof HyperlinkComponent
*/
@Input()
set text(value: string) {
this.textInternal = value;
}
get text(): string {
return this.model?.Text ?? this.textInternal;
}
/**
* Gets/sets the navigateUrl property.
*
* @memberof HyperlinkComponent
*/
@Input()
set navigateUrl(value: string) {
this.navigateUrlInternal = value;
}
get navigateUrl(): string {
return this.model?.NavigateUrl ?? this.navigateUrlInternal;
}
/**
* Gets/sets the enabled property.
*
* @memberof HyperlinkComponent
*/
@Input()
set enabled(value: boolean) {
this.enabledInternal = value;
}
get enabled(): boolean {
return this.model?.Enabled ?? this.enabledInternal;
}
/**
* Gets/sets the cssClass property.
*
* @memberof HyperlinkComponent
*/
@Input()
set cssClass(value: string) {
this.cssClassInternal = value;
}
get cssClass(): string {
return this.model?.CssClass ?? this.cssClassInternal;
}
/**
* Gets the visible property.
*
* @readonly
* @type {boolean}
* @memberof HyperlinkComponent
*/
get visible(): boolean {
return this.model?.Visible != null ? this.model.Visible : true;
}
/**
* Returns the attributes object from the model.
*
* @return {*} {*}
* @memberof HyperlinkComponent
*/
getAttributesObject(): any {
return {
Attributes: this.model?.Attributes
};
}
/**
* Returns the css classes to be applied.
*
* @return {*} {string}
* @memberof HyperlinkComponent
*/
getClasses(): string {
let classes = '';
classes = this.class ? `${this.class} ${this.cssClass}` : this.cssClass;
/* c8 ignore else */
if (!this.enabled) {
return classes.concat(' disabled');
}
return classes;
}
/**
* Handler for the click.
*
* @param {*} event
* @memberof HyperlinkComponent
*/
clickHandler(event: any) {
/* c8 ignore else */
if (this.enabled) {
this.triggerNavigateToPage(event);
}
}
/**
* Triggers the NavigateToUrl emitter.
*
* @param {*} event
* @memberof HyperlinkComponent
*/
@serverEvent('NavigateToUrl')
triggerNavigateToPage(event: any): void {
this.NavigateToUrl.emit(new EventData(event, this.id));
}
}
<a *ngIf="model && visible" href="javascript:void(0)" (click)="clickHandler($event)" [ngClass]="getClasses()"
[model]="getAttributesObject()" wmHtmlControl wmControls [hostComponent]="this">
{{text}}
<ng-content></ng-content>
</a>
./hyperlink.component.scss
a.disabled {
cursor: text;
}