File

src/reactive-form/switch/switch.component.ts

Metadata

selector tw-switch
template   <div [formGroup]='group'>
  <label class="switch switch-icon switch-pill switch-primary-outline-alt">
        <input type="checkbox" [formControlName]='field.id' class="switch-input"  [(ngModel)]="request[field.id]" >
        <span class="switch-label" data-on="yes" data-off="no"></span>
        <span class="switch-handle"></span>
    </label>
</div>

Inputs

field

Type: FormField

group

Type: FormGroup

request

Type: any

import { Component, Input } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { FormField } from '../form-field.model'

@Component({
  selector: 'tw-switch',
  template: `
  <div [formGroup]='group'>
  <label class="switch switch-icon switch-pill switch-primary-outline-alt">
        <input type="checkbox" [formControlName]='field.id' class="switch-input"  [(ngModel)]="request[field.id]" >
        <span class="switch-label" data-on="yes" data-off="no"></span>
        <span class="switch-handle"></span>
    </label>
</div>
  `
})
export class SwitchComponent {
  @Input() group: FormGroup
  @Input() field: FormField
  @Input() request: any
}

results matching ""

    No results matching ""