Set default value for angular material datePicker with angular 5

前端 未结 8 656
独厮守ぢ
独厮守ぢ 2021-01-11 13:14

I\'m using a date picker from angular material. I want to set a default value but it is not showing the value.



        
8条回答
  •  南笙
    南笙 (楼主)
    2021-01-11 13:45

    You need to provide a Date object to the startAt change as below:

    In .ts:

    date = new Date((new Date().getTime() - 3888000000));
    

    In html:

    
    

    A working demo here: https://stackblitz.com/edit/angular-n9yojx

提交回复
热议问题