All files / app/formly radio.type.ts

40% Statements 6/15
50% Branches 6/12
100% Functions 1/1
28.57% Lines 2/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3110x                                                         10x  
import { AsyncPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { FieldType, FieldTypeConfig, FormlyAttributes } from '@ngx-formly/core';
import { FormlySelectModule } from '@ngx-formly/core/select';
 
@Component({
  selector: 'formly-field-radio',
  template: `
    @for (option of props.options | formlySelectOptions: field | async; track option.value; let i = $index) {
      <input type="radio"
             [id]="id + '_' + i"
             [class.is-invalid]="showError"
             [attr.value]="option.value"
             [value]="option.value"
             [formControl]="formControl"
             [formlyAttributes]="field"
             [attr.disabled]="option.disabled || formControl.disabled ? true : null">
      <label [for]="id + '_' + i">{{ option.label }}</label>
    }
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [
    ReactiveFormsModule,
    AsyncPipe,
    FormlySelectModule,
    FormlyAttributes,
  ],
})
export class FormlyFieldRadio extends FieldType<FieldTypeConfig> { }