File

src/ng-xform/checkbox-field/checkbox-field.component.ts

Description

Component to generate a form checkbox field

:editing: Flag to control component state :form: FormGroup containing the field :field: Intance of field configurations

Extends

BaseDynamicFieldComponent

Implements

AfterContentInit OnInit

Metadata

selector ng-xform-checkbox-field
templateUrl ./checkbox-field.component.html

Index

Properties
Methods
Accessors

Methods

ngAfterContentInit
ngAfterContentInit()
Returns : void

Properties

hideLabelOnEdit
hideLabelOnEdit:
Default value : true

Accessors

formattedValue
getformattedValue()
import { Component, AfterContentInit, OnInit } from '@angular/core';

import { BaseDynamicFieldComponent } from '../field-components/base-dynamic-field.component';
import { CheckboxField } from '../fields';


/**
 * Component to generate a form checkbox field
 *
 * :editing: Flag to control component state
 * :form: FormGroup containing the field
 * :field: Intance of field configurations
 */
@Component({
  selector: 'ng-xform-checkbox-field',
  templateUrl: './checkbox-field.component.html',
})
export class CheckboxFieldComponent extends BaseDynamicFieldComponent<CheckboxField> implements AfterContentInit, OnInit {
  hideLabelOnEdit = true;

  ngAfterContentInit() {
    if (this.control.value === null) {
      // this setTimeout is to avoid ERROR TypeError
      // TODO: Remove after RFDAP-593
      setTimeout(() => this.control.setValue(!!this.control.value));
    }
  }

  get formattedValue(): string {
    return this.form.controls[this.elementId].value ? 'True' : 'False';
  }

}
<ng-xform-form-control-layout [fieldComponent]="instance">
<div class="checkbox">
    <label>
      <input type="checkbox" [formControl]="control" id="{{elementId}}" /> {{field.label}}
    </label>
  </div>
</ng-xform-form-control-layout>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""