projects/i-components/src/lib/components/combo-box-item/combo-box-item.component.ts
ComboBoxItem component
changeDetection | ChangeDetectionStrategy.OnPush |
selector | wm-combo-box-item |
styleUrls | ./combo-box-item.component.scss |
templateUrl | ./combo-box-item.component.html |
Properties |
Methods |
Inputs |
Public
constructor(injectedModel: ComboBoxItemModel, element: ElementRef)
|
|||||||||
Creates an instance of ComboBoxItem.
Parameters :
|
model | |
Type : ComboBoxItemModel
|
|
Object with ComboBoxItem properties and events |
ngAfterViewInit |
ngAfterViewInit()
|
Angular lifecycle hook Initialize model
Returns :
void
|
ngOnInit |
ngOnInit()
|
Angular lifecycle hook Initialize model
Returns :
void
|
Public model |
Type : ComboBoxItemModel
|
Decorators :
@Input()
|
Object with ComboBoxItem properties and events |
template |
Type : TemplateRef<any>
|
Decorators :
@ViewChild('itemTemplate')
|
Template reference with the content |
import {
ChangeDetectionStrategy,
Component,
Input,
OnInit,
Optional,
TemplateRef,
ViewChild,
AfterViewInit,
ElementRef,
} from '@angular/core';
import {
ComboBoxItemModel,
AngularComponentId,
ComponentId,
} from '@mobilize/wms-framework';
/**
* ComboBoxItem component
*
* @export
* @class ComboBoxItemComponent
* @implements {OnInit}
* @implements {AfterViewInit}
*/
@Component({
selector: 'wm-combo-box-item',
templateUrl: './combo-box-item.component.html',
styleUrls: ['./combo-box-item.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
@ComponentId([AngularComponentId.comboBoxItem])
export class ComboBoxItemComponent implements OnInit, AfterViewInit {
/**
* Template reference with the content
*
* @type {TemplateRef<any>}
* @memberof ComboBoxItemComponent
*/
@ViewChild('itemTemplate')
template: TemplateRef<any>;
/**
* Object with ComboBoxItem properties and events
*
* @type {ComboBoxItemModel}
* @memberof ComboBoxItemComponent
*/
@Input()
public model: ComboBoxItemModel;
/**
* Creates an instance of ComboBoxItem.
*
* @param {ComboBoxItemModel} injectedModel
* @memberof ComboBoxItemComponent
*/
public constructor(
@Optional() private injectedModel: ComboBoxItemModel,
private element: ElementRef
) {
this.model = injectedModel;
}
/**
* Angular lifecycle hook
* Initialize model
*
* @memberof ComboBoxItemComponent
*/
ngOnInit(): void {
this.model = this.model || this.injectedModel || new ComboBoxItemModel();
}
/**
* Angular lifecycle hook
* Initialize model
*
* @memberof ComboBoxItemComponent
*/
ngAfterViewInit(): void {
/* istanbul ignore else */
if (!this.model.Content) {
this.model.Content = this.element.nativeElement?.childNodes[0].innerText;
}
}
}
<ng-container *ngTemplateOutlet="itemTemplate"></ng-container>
<ng-template #itemTemplate>
<span>
{{ model?.Content }}
<ng-content></ng-content>
</span>
</ng-template>
./combo-box-item.component.scss