File

projects/i-components/src/lib/components/combo-box-item/combo-box-item.component.ts

Description

ComboBoxItem component

Implements

OnInit AfterViewInit

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector wm-combo-box-item
styleUrls ./combo-box-item.component.scss
templateUrl ./combo-box-item.component.html

Index

Properties
Methods
Inputs

Constructor

Public constructor(injectedModel: ComboBoxItemModel, element: ElementRef)

Creates an instance of ComboBoxItem.

Parameters :
Name Type Optional
injectedModel ComboBoxItemModel No
element ElementRef No

Inputs

model
Type : ComboBoxItemModel

Object with ComboBoxItem properties and events

Methods

ngAfterViewInit
ngAfterViewInit()

Angular lifecycle hook Initialize model

Returns : void
ngOnInit
ngOnInit()

Angular lifecycle hook Initialize model

Returns : void

Properties

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

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""