I have a form in which there is a local and a permanent field. I want to copy all local fields to the permanent field if the user checked the checkbox, or if the user unchecked the checkbox I need to blank all the permanent fields.
I tried this: https://stackblitz.com/edit/angular-ypzjrk?file=src%2Fapp%2Fapp.component.ts
import { Component } from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
cf: FormGroup;
isChecked:boolean;
constructor(private fb: FormBuilder){
this.isChecked = false;
this.cf = this.fb.group({
district: [''],
city: [''],
permanentDistrict: [''],
permanentCity: [''],
})
}
checkValue(){
alert(this.isChecked);
}
}