src/lib/components/template-field/template-field.component.ts
Angular Component for the TemplateField Control.
providers |
{ provide: DataControlFieldComponent, useExisting: TemplateFieldComponent }
|
selector | wm-template-field |
styleUrls | ./template-field.component.scss |
templateUrl | ./template-field.component.html |
Properties |
|
Methods |
Inputs |
constructor(wmService: WebMapService, refChange: ChangeDetectorRef, render2: Renderer2, elem: ElementRef, webComponents: WebComponentsService, bringTopServ1: BringTopService)
|
|||||||||||||||||||||
Creates an instance of TemplateFieldComponent.
Parameters :
|
headerText | |
Type : string
|
|
Inherited from
DataControlFieldComponent
|
|
Defined in
DataControlFieldComponent:94
|
|
Gets/sets the headerText property. |
sortExpression | |
Type : string
|
|
Inherited from
DataControlFieldComponent
|
|
Defined in
DataControlFieldComponent:108
|
|
Gets/sets the sortExpression property. |
visible | |
Type : boolean
|
|
Inherited from
DataControlFieldComponent
|
|
Defined in
DataControlFieldComponent:144
|
|
Gets/sets the visible property. |
setItemTemplateModels | ||||||
setItemTemplateModels(controlsIds: any[])
|
||||||
Resolves and sets the models for each child item in the ItemTemplate.
Parameters :
Returns :
void
|
isBindedEvent | ||||||
isBindedEvent(event: string)
|
||||||
Inherited from
DataControlFieldComponent
|
||||||
Defined in
DataControlFieldComponent:170
|
||||||
Override the isBindedEvent to get the event from the Field model
Parameters :
Returns :
boolean
{boolean} |
itemTemplate |
Type : TemplateRef<any>
|
Decorators :
@ContentChild('ItemTemplate')
|
ItemTemplate reference. |
itemTemplateModels |
Type : any[]
|
Default value : []
|
ItemTemplate children models. |
Private headerTextInternal |
Type : string
|
Default value : ''
|
Inherited from
DataControlFieldComponent
|
Defined in
DataControlFieldComponent:50
|
Property to save the headerText value. |
Private sortExpressionInternal |
Type : string
|
Default value : ''
|
Inherited from
DataControlFieldComponent
|
Defined in
DataControlFieldComponent:58
|
Property to save the sortExpression value. |
Private visibleInternal |
Default value : true
|
Inherited from
DataControlFieldComponent
|
Defined in
DataControlFieldComponent:66
|
Property to save the visible value. |
import {
ChangeDetectorRef,
Component,
ContentChild,
ElementRef,
Optional,
Renderer2,
TemplateRef
} from '@angular/core';
import { dataTransfer, BringTopService } from '@mobilize/base-components';
import { WebMapService } from '@mobilize/angularclient';
import { ErrorCodes, ExceptionHandlerClass } from '@mobilize/webmap-core';
import { WebComponentsService } from '@mobilize/winforms-components';
import { DataControlFieldComponent } from '../data-control-field/data-control-field.component';
/**
* Angular Component for the TemplateField Control.
*
* @export
* @class TemplateFieldComponent
* @extends {DataControlFieldComponent}
*/
@Component({
selector: 'wm-template-field',
templateUrl: './template-field.component.html',
styleUrls: ['./template-field.component.scss'],
providers: [
{ provide: DataControlFieldComponent, useExisting: TemplateFieldComponent }
],
inputs: ['model']
})
@dataTransfer(['tmpltfld'])
@ExceptionHandlerClass(ErrorCodes.Winforms)
export class TemplateFieldComponent extends DataControlFieldComponent {
/**
* ItemTemplate reference.
*
* @type {TemplateRef<any>}
* @memberof TemplateFieldComponent
*/
@ContentChild('ItemTemplate')
itemTemplate!: TemplateRef<any>;
/**
* ItemTemplate children models.
*
* @type {any[]}
* @memberof TemplateFieldComponent
*/
itemTemplateModels: any[] = [];
/**
* Creates an instance of TemplateFieldComponent.
*
* @param {WebMapService} wmService
* @param {ChangeDetectorRef} refChange
* @param {Renderer2} render2
* @param {ElementRef} elem
* @param {WebComponentsService} webComponents
* @param {BringTopService} bringTopServ1
* @memberof TemplateFieldComponent
*/
constructor(
private wmService: WebMapService,
private refChange: ChangeDetectorRef,
private render2: Renderer2,
private elem: ElementRef,
webComponents: WebComponentsService,
@Optional() private bringTopServ1: BringTopService
) {
super(refChange, render2, elem, webComponents, bringTopServ1);
}
/**
* Resolves and sets the models for each child item in the ItemTemplate.
*
* @param {any[]} controlsIds. Collection of {"name": "id"} objects to resolve the models.
* @memberof TemplateFieldComponent
*/
setItemTemplateModels(controlsIds: any[]): void {
this.itemTemplateModels = [];
controlsIds.forEach((iteration: any) => {
const iterationKeys = Object.keys(iteration);
const iterationModels: any = {};
iterationKeys.forEach((controlName) => {
iterationModels[controlName] = this.wmService.core.getModel(
iteration[controlName]
);
});
this.itemTemplateModels.push(iterationModels);
});
}
}
<ng-content></ng-content>
./template-field.component.scss