Input with the date of the respective day, without being able to be edited

Asked

Viewed 80 times

3

I need an input to come with the date of the respective day, for example today: 17/11/2015, tomorrow 18/11/2015. This input cannot allow edits.

My code is like this:

<label class="item item-input">
    <span class="cinza input-label">Data:</span>
    <input class="cinza" type="date">
</label>

1 answer

7


You can assign a variable with the current date in the input value, and mark it as readonly so it is not edited.

<input class="cinza" readonly type="date" value="{{data| date:'dd-MMM-yyyy'}}">

In the controller, $scope.data = new Date();

  • 4

    Just be careful, 'cause input="date" does not work in all browsers and this can give you a lot of headache (as it is with me). Then check this date portability need.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.