From 7183b776772ef8876f8f0f77129cf549da4dcfd8 Mon Sep 17 00:00:00 2001 From: Anand raja Date: Fri, 4 Oct 2024 10:40:52 +0000 Subject: [PATCH] form array completed --- src/app/reactive/signup/signup.component.html | 20 +++++++++---------- src/app/reactive/signup/signup.component.ts | 13 ++++++++++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/app/reactive/signup/signup.component.html b/src/app/reactive/signup/signup.component.html index 7d7f489..abcdb5b 100644 --- a/src/app/reactive/signup/signup.component.html +++ b/src/app/reactive/signup/signup.component.html @@ -42,7 +42,7 @@

Welcome on board!

- +
@@ -70,7 +70,7 @@

Welcome on board!

- @@ -85,35 +85,35 @@

Welcome on board!

- +
- +
- +

-
+
How did you find us?
- +
- +
- +
@@ -121,7 +121,7 @@

Welcome on board!

diff --git a/src/app/reactive/signup/signup.component.ts b/src/app/reactive/signup/signup.component.ts index 63d9306..ca5080f 100644 --- a/src/app/reactive/signup/signup.component.ts +++ b/src/app/reactive/signup/signup.component.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; +import { FormArray, FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; @Component({ selector: 'app-signup', @@ -43,10 +43,19 @@ export class SignupComponent { validators: [Validators.required], }), }), + role: new FormControl<'student' | 'teacher' | 'employee' | 'founder' | 'other'>('student', { + validators: [Validators.required], + }), + gender: new FormControl<'male' | 'female' | 'others' | null>(null, { + validators: [Validators.required], + }), + source: new FormArray([new FormControl(false), new FormControl(false), new FormControl(false)]), + agree: new FormControl(false, { validators: [Validators.required] }), }); onSubmit() { - console.log(this.formObj.value); + console.log('this.formObj => ', this.formObj); + console.log('this.formObj.value => ', this.formObj.value); } onReset() {