File

projects/i-components/src/lib/services/radiobuttonsnames.service.ts

Description

Service to get the group name for radio buttons.

Index

Properties
Methods

Constructor

constructor()

Creates an instance of RadioNameService.

Methods

Public getGroupName
getGroupName()

Gets the group name.

Returns : string

{string} The group name.

Properties

Static counter
Type : number
Default value : 0

Stores the id of the last generated group name.

Private id
Type : string
Default value : ''

Stores the ID for the current group.

Public sync
Type : EventEmitter<any>
Default value : new EventEmitter<any>()

Sync.

import { Injectable, EventEmitter } from '@angular/core';

/**
 * Service to get the group name for radio buttons.
 *
 * @export
 * @class RadioNameService
 */
@Injectable({
  providedIn: 'root',
})
export class RadioNameService {
  /**
   * Stores the id of the last generated group name.
   *
   * @static
   * @memberof RadioNameService
   */
  static counter = 0;

  /**
   * Sync.
   *
   * @type {EventEmitter<any>}
   * @memberof RadioNameService
   */
  public sync: EventEmitter<any> = new EventEmitter<any>();

  /**
   * Stores the ID for the current group.
   *
   * @private
   * @memberof RadioNameService
   */
  private id = '';

  /**
   * Creates an instance of RadioNameService.
   *
   * @memberof RadioNameService
   */
  constructor() {
    this.id = `radioButtonGroup${++RadioNameService.counter}`;
  }

  /**
   * Gets the group name.
   *
   * @return {*}  {string} The group name.
   * @memberof RadioNameService
   */
  public getGroupName(): string {
    return this.id;
  }
}

result-matching ""

    No results matching ""