How can I set my reactive form date input value?

前端 未结 3 1260
傲寒
傲寒 2021-02-08 13:30

So I am trying to display this date for an input. But it\'s not displaying when setting the value of it in my form builder group. I would also like to be able to format it too.<

3条回答
  •  耶瑟儿~
    2021-02-08 13:42

    Try the built-in formatDate package.

    import { formatDate } from '@angular/common' 
    

    and then convert your date and set it to the datepicker control

    this.yourForm.controls.controlName.setValue(formatDate(date,'yyyy-MM-dd','en'));
    

提交回复
热议问题