-
- Star
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Note:: Give Skills as comma separated e.g. java,python
+
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index defff55..2c6dff4 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,10 +1,63 @@
-import { Component } from '@angular/core';
-
+import { Component, OnInit } from '@angular/core';
+import { FormBuilder,Validators,FormGroup, FormControl } from "@angular/forms";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
-export class AppComponent {
- title = 'angular-forms-add-or-remove-control';
+export class AppComponent implements OnInit{
+
+ public form:FormGroup;
+ constructor(private formBuilder:FormBuilder){
+ this.formInit()
+ }
+
+ public ngOnInit(): void {
+ this.form.get('workStatus').valueChanges.subscribe(value=>{
+ this.selectionChange(value);
+ })
+ }
+
+ public formInit(){
+ this.form = this.formBuilder.group({
+ firstName:['', Validators.required],
+ secondName:['', Validators.required],
+ middleName:[''],
+ username:['', Validators.required],
+ email:['', Validators.required],
+ mobile:['', [Validators.required,Validators.minLength(10),Validators.maxLength(10)]],
+ password:['', Validators.required],
+ workStatus:['', Validators.required],
+ gender:['', Validators.required],
+ qualifications:[[]],
+ })
+ }
+
+ public resetForm(){
+ this.form.reset()
+ }
+
+ public get isExperienced(){
+ const value = this.form.get('workStatus').value;
+ return value && value === 'Experienced';
+ }
+
+ public selectionChange(value) {
+ if(value && value === 'Experienced'){
+ this.form.addControl('workExperience',new FormControl('',[Validators.required]));
+ this.form.addControl('currentCompany',new FormControl('',[Validators.required]));
+ this.form.addControl('currentCtc',new FormControl('',[Validators.required]));
+ this.form.addControl('expectedCtc',new FormControl('',[Validators.required]));
+ this.form.addControl('noticePeriod',new FormControl('',[Validators.required]));
+ this.form.addControl('skills',new FormControl('',[Validators.required]));
+ }else{
+ this.form.removeControl('workExperience');
+ this.form.removeControl('currentCompany');
+ this.form.removeControl('currentCtc');
+ this.form.removeControl('expectedCtc');
+ this.form.removeControl('noticePeriod');
+ this.form.removeControl('skills');
+ }
+ }
+
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 2c3ba29..71046fc 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -3,6 +3,7 @@ import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@NgModule({
declarations: [
@@ -10,7 +11,9 @@ import { AppComponent } from './app.component';
],
imports: [
BrowserModule,
- AppRoutingModule
+ AppRoutingModule,
+ FormsModule,
+ ReactiveFormsModule
],
providers: [],
bootstrap: [AppComponent]
diff --git a/src/styles.scss b/src/styles.scss
index 90d4ee0..84f7dc2 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -1 +1 @@
-/* You can add global styles to this file, and also import other style files */
+@import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
\ No newline at end of file