Material: Placeholder on md-datepicker doesn't show up when using custom format function

Created on 18 May 2016  路  6Comments  路  Source: angular/material

When using custom format function $mdDateLocaleProvider.formatDate placeholder on md-datepicker is not shown. Instead today's date is displayed. Demo on plunker: http://plnkr.co/edit/O5ePYKyo1ILlheMz8KdO?p=preview

If you comment/remove formatDate function from config, placeholder is working.

angular-material version: 1.1.0-rc2

Most helpful comment

It seems like Moment defaults to today's date if the model is undefined. You can rewrite your function like this:

function formatDate(date) {
  return date ? moment(date).format('L') : '';
}

All 6 comments

It seems like Moment defaults to today's date if the model is undefined. You can rewrite your function like this:

function formatDate(date) {
  return date ? moment(date).format('L') : '';
}

@crisbeto Thanks a lot! This solution solved my issue.

Cool, glad to help.

Thanks!

I had same issue. thanks @crisbeto

Nice, also working for me !!

Was this page helpful?
0 / 5 - 0 ratings