Change format of md-datepicker in Angular Material with momentjs

前端 未结 13 825
再見小時候
再見小時候 2020-11-28 09:01

Angular material introduced a new date picker component found here.

I want the date returned by this component to be in the format yyy-mm-dd but I am not su

13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 09:32

    in my case I was loosing the PlaceHolder everythig works but the placeHolder was disappearing when I use custom formatting. Below lines solved my problem with placeholder.

    $mdDateLocaleProvider.formatDate = function (date) {
                    if(date==null)
                    return "";
                    var m = moment(date);
                    return m.isValid() ? m.format('L') : '';
                };
    

提交回复
热议问题