如何使用日期选取器在角2? [英] How to use date picker in Angular 2?

查看:365
本文介绍了如何使用日期选取器在角2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过很多日期选取器在我angular2应用程序,但他们都不是working.Although日期选取器显示的看法,但选定日期的价值没有在ngModel变量中获得。

I have tried many date picker in my angular2 app but none of them is working.Although the date picker is displaying on the view but the value of selected date is not getting in the ngModel variable.

推荐答案

在事实上,你可以通过简单地添加日期值到<$ C $使用一个datepicker C>键入您的输入属性:

In fact, you can use a datepicker by simply adding the date value into the type attribute of your inputs:

<input type="date" [(ngModel)]="company.birthdate"/>

在Chrome等(不能在Firefox)浏览器的一些,你可以在输入中点击图标来显示日期选择器。图标只有当你的鼠标是在输入出现。

In some browsers like Chrome (not in Firefox), you can click on the icon within the input to display the date picker. Icons appear only when you mouse is over the input.

要有事跨浏览器,你应该考虑使用符合Angular2库,例如:

To have something cross browsers, you should consider to use Angular2 compliant libraries like:

  • https://github.com/kekeh/mydatepicker
  • https://github.com/jkuri/ng2-datepicker

希望它可以帮助你,
蒂埃里

Hope it helps you, Thierry

这篇关于如何使用日期选取器在角2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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