Angular 2 reaktywne formularze przycisk opcji domyślnie sprawdzony
HTML file:
<form [formGroup]="form" (ngSubmit)="onSubmit()">
<input type="radio" formControlName="skill" [value]="skillsForBackend[0]">
<input type="radio" formControlName="skill" [value]="skillsForBackend[1]">
</form>
TS file:
ngOnInit() {
this.form = this.fb.group({
skill: [this.skillsForBackend[0], Validators.required]
});
}
onSubmit() {
console.log(this.form.value) // should show { skill: /* your data */ }
}
Malhaar Punjabi