angular-custom-form/src/app/radio.component.ts
2022-03-01 13:58:54 -06:00

38 lines
727 B
TypeScript

import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'app-radio',
template: `
<div class="radio">
<div *ngFor="let choice of field.options.choices">
<input type="radio" name="field.id" class="choice"
[value]="choice"
[(ngModel)]="field.value"
(ngModelChange)="check()"
/>
<label>{{ choice }}</label>
</div>
</div>
`
})
export class RadioComponent implements OnInit {
@Input() field: Field;
@Output() update: EventEmitter<null> = new EventEmitter();
ngOnInit() { console.log("Radio", this.field.id); }
check() {
this.field.ok = true;
this.update.emit();
}
}