I'm working with a nested form setup that looks like this:
profileForm = new FormGroup({
firstName: new FormControl(''),
lastName: new FormControl(''),
address: new FormGroup({
street: new FormControl(''),
city: new FormControl(''),
date1: new FormControl(''),
date2: new FormControl('')
})
});
My goal is to make the date2
minimum date dependent on the value of date1
, as shown below:
<mat-form-field class="datepickerformfield" floatLabel="never">
<input matInput class="dp" formControlName="date2" [min]="profileform.controls['date1'].value" [matDatepicker]="date2" placeholder="DD/MM/YYYY" >
</mat-form-field>
I've also attempted:
[min]="profileform.address.controls['date1'].value"
And
[min]="profileform.controls[address].controls['date1'].value"
However, I keep receiving an error message stating:
Cannot read property 'value' of undefined
How can I properly access the value of date1
using the profileform
object?