【发布时间】:2019-10-04 14:25:31
【问题描述】:
我有一个类似于以下的嵌套表单:
profileForm = new FormGroup({
firstName: new FormControl(''),
lastName: new FormControl(''),
address: new FormGroup({
street: new FormControl(''),
city: new FormControl(''),
date1: new FormControl(''),
date2: new FormControl('')
})
});
我正在尝试将 date2 mindate 设置为 date1 值,如下所示:
<mat-form-field class="datepickerformfield" floatLabel="never">
<input matInput class="dp" formControlName="date2" [min]="profileform.controls['date1'].value" [matDatepicker]="date2" placeholder="DD/MM/AAAA" >
</mat-form-field>
也尝试过:
[min]="profileform.address.controls['date1'].value"
和
[min]="profileform.controls[address].controls['date1'].value"
但我得到一个错误:
无法读取未定义的属性“值”
如何使用profileform 对象获取date1 值?
【问题讨论】:
-
可以分享到stackbiltz吗
-
profileForm.get('address').get('date1') -
[min]="profileform.get('address').get('date1').value",或[min]="profileform.get('address.date1').value"
标签: angular forms typescript