moh-common-lib
Version:
A library of Angular components, services, and styles for B.C. Government Ministry of Health (MoH).
57 lines (56 loc) • 1.98 kB
TypeScript
import { EventEmitter, OnInit } from '@angular/core';
import { AbstractFormControl } from '../../models/abstract-form-control';
import { ErrorMessage } from '../../models/error-message.interface';
import { NgControl } from '@angular/forms';
/**
* RadioComponent is a single radio which can be used to have multiple radios
* based on the radio label values.
*
* To display radio in a vertical style use display="table-row-group" by default
* it shows in horizontal or inline display, display='inline-block' You can
* have many radio's and the number is based on the Radio label Value. For 3
* radio buttons, radioLabels value is of type IRadioItems[].
*
* @example
*
* Reactive Form
* <common-radio name='choice'
* label='Do you live in Canada'
* display='table-row-group'
* [radioLabels]=='[{label: "No", value: false},{label: "Yes", value: true}]'
* FormControlName='choice'>
* </common-radio>
*
* Template Form
* <common-radio name='ageCategory'
* [(ngModel)]="age"
* label='How old are you?'
* display='table-row-group'
* [radioLabels]='[{label: "0-18 years", value: 0},{label: "19 years and older", value: 1}]'>
* </common-radio>
*
* @export
*
*/
export interface IRadioItems {
label: string;
value: any;
}
export declare class RadioComponent extends AbstractFormControl implements OnInit {
controlDir: NgControl;
_value: any;
_defaultErrMsg: ErrorMessage;
radioLabels: IRadioItems[];
required: boolean;
label: string;
value: any;
display: 'table-row-group' | 'inline-block';
instructionText: string;
valueChange: EventEmitter<any>;
constructor(controlDir: NgControl);
ngOnInit(): void;
setStatus(val: any): void;
registerOnChange(fn: any): void;
registerOnTouched(fn: any): void;
writeValue(value: any): void;
}