输入字段更改时的angularJs日期格式 [英] angularJs date formatting on input field change

查看:63
本文介绍了输入字段更改时的angularJs日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我输入日期的字段:

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>

该字段的值根据智能表中选择的项目进行更新。问题是选择项目时显示的是时间戳,我需要它采用 dd / mm / yyyy格式。在这种情况下,如何在不修改$ scope值的情况下应用过滤器?

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?

推荐答案

您可以通过添加 |日期:'dd / MM / yyyy'与您绑定。像这样:

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>

这篇关于输入字段更改时的angularJs日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆