38 lines
727 B
TypeScript
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();
|
|
|
|
}
|
|
|
|
}
|