Tombol Radio Formulir Reaktif Angular 2 Secara Default Diperiksa
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