File

src/app/shared/components/details-label/details-label.component.ts

Description

Reusable component that takes an array of strings and renders that array as a string, separated by commas, in the icon color.

Metadata

Index

Properties
Methods
Inputs
HostBindings

Inputs

details
Type : string[]
Default value : []

The array of details to be displayed.

HostBindings

class
Type : "ccf-details-label"
Default value : 'ccf-details-label'

HTML Class Name

Methods

arrayToString
arrayToString(inputArray: string[])

Function that handles converting the array given into a formatted string for display.

Parameters :
Name Type Optional Description
inputArray string[] No

an array of strings to join.

Returns : string

the formatted string of items separated by a comma.

Properties

Readonly clsName
Type : string
Default value : 'ccf-details-label'
Decorators :
@HostBinding('class')

HTML Class Name

import { ChangeDetectionStrategy, Component, HostBinding, Input } from '@angular/core';

/**
 * Reusable component that takes an array of strings and renders
 * that array as a string, separated by commas, in the icon color.
 */
@Component({
  selector: 'ccf-details-label',
  templateUrl: './details-label.component.html',
  styleUrls: ['./details-label.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DetailsLabelComponent {
  /** HTML Class Name */
  @HostBinding('class') readonly clsName = 'ccf-details-label';

  /**
   * The array of details to be displayed.
   */
  @Input() details: string[] = [];

  /**
   * Function that handles converting the array given
   * into a formatted string for display.
   *
   * @param inputArray an array of strings to join.
   * @returns the formatted string of items separated by a comma.
   */
  arrayToString(inputArray: string[]): string {
    return inputArray.filter((item) => !!item).join(', ');
  }
}
{{ arrayToString(details) }}

./details-label.component.scss

:host {
  display: block;
  height: 2.25rem;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""