📜  Angular 材质日期选择器自动添加日期 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:20.294000             🧑  作者: Mango

代码示例1
As you are using Angular Reactive forms, you can listen for changes in the dateOne form control value through the valueChanges observable and set the dateTwo form control value.

this.form.get('dateOne')?.valueChanges.subscribe(date => {
  const dateTwo = formatDate(new Date()+ 7, 'MM/dd/yyyy', 'en');
  this.form.get('dateTwo')?.setValue(dateTwo);
});