Ionic 2: missing placeholder attribute for ion-datetime

Hello, this is my first post here so apologies upfront for anything i’m doing wrong here.

I am wondering if the placeholder attribute works for the ion-datetime element? Looks like placholder works for at least ion-select and ion-input but doesn’t appear to work for ion-datetime. I’m hoping i’m doing something wrong and that it isn’t simply placeholder hasn’t been or won’t be implemented for ion-datetime. Does anyone know if placeholder works for ion-datetime?

or

Does anyone know of a workaround for me?

Thanks,
Jeff

2 Likes

I am also interested in a work around for this.

Thanks

I have managed a work around using css for myself. Might not work for what you need it for but for myself i used the following:

.datetime-text:empty:not(:focus):before{
    content: "Please select a date"
}

hope it helps

3 Likes

Thanks cooLLede, I can confirm this works. We decided to move to using the stacked attribute on the label elements instead of using placeholders. figured this would lesson the chance we would have to refactor later on down the line as the ionic 2 framework gets more mature.

1 Like

it works but the ion-datetime has a weird right aligment that make the placeholder does not display correctly. Someone has provided a patch to support placeholder for ion-datetime but its still not been accepted.

Looks like there is a placeholder option currently in the master branch. https://github.com/driftyco/ionic/pull/7967

2 Likes