使用angular.js输入类型时间 [英] Input type time with angular.js

查看:185
本文介绍了使用angular.js输入类型时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档输入[时间]: https://docs .angularjs.org/api/ng/input/input%5Btime%5D

使用输入类型时间并将其绑定到日期对象就足够了,但是它不能按我期望的那样工作.

<input ng-model="time" type="time" placeholder="HH:mm" min="08:00" max="17:00" required >

$scope.time = new Date();

作为结果,我只想在输入字段中看到HH:mm.

这是一个玩耍的jsfiddle:

http://jsfiddle.net/U3pVM/7314/

解决方案

我认为您至少需要 Angular 1.3.0 beta 才能正常工作,因为它似乎是在随后引入的./p>

更改日志:

...

功能

输入:支持类型日期,时间,本地日期时间,月,周 ( 46bd6dc8 https://docs.angularjs.org/api/ng/input/input%5Btime%5D

it should be enough to use the input type time and bind it to a date oject, however it doesn't work as I'd expect it.

<input ng-model="time" type="time" placeholder="HH:mm" min="08:00" max="17:00" required >

and

$scope.time = new Date();

as a Result I'd like to see just the HH:mm within the input field.

Here's a jsfiddle to play around:

http://jsfiddle.net/U3pVM/7314/

解决方案

I think you need at least Angular 1.3.0 beta for this to work, as it looks like it was introduced then.

Changelog:

...

Features

input: support types date, time, datetime-local, month, week (46bd6dc8, #5864)
....

这篇关于使用angular.js输入类型时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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