简体   繁体   中英

angularJs date formatting on input field change

This is my input field for date:

        <div class="input-group date">
            <input type="text" class="form-control" id="datepicker" placeholder="dd/mm/yyyy" ng-model="abs.date">
        </div>

value of this field is updated based on item selected in smart table. The problem is that what is displayed upon selecting an item is a timestamp and i need it to be in "dd/mm/yyyy" format. How do i apply a filter in this case without modifying the $scope value behind it?

You can do that by adding "| date:'dd/MM/yyyy'" to you binding. Like this:

<div class="input-group date">
            <input type="text" class="form-control" id="datepicker" placeholder="dd/mm/yyyy" ng-model="abs.date | date:'dd/MM/yyyy'">
        </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM