Angularjs与引导,日期选择器:输入不积极被认可 [英] Angularjs with Bootstrap-Datepicker: input not actively being recognized

查看:125
本文介绍了Angularjs与引导,日期选择器:输入不积极被认可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个使用引导,日期选择器的AngularJS应用。

I'm trying to create an AngularJS application using bootstrap-datepicker.

下面是我的HTML:

<div id="test" class="input-append date">
  <input type="text" ng-model="datepicker.date" class="span4">
  <span class="add-on"><i class="icon-th"></i></span>
</div>
{{ datepicker.date }}

最后一行是用于调试目的。当这个页面是在行动中,日期选择器工作正常,并写入我挑到输入框中的任何日期。问题是,当我点击一个日期, {{} datepicker.date} 部分不显示任何东西,直到我手动输入的东西到输入框。我想它积极展现我挑选任何日期。

The last line is for debugging purposes. When this page is in action, the datepicker works fine and writes any date I pick into the input box. The issue is, as I click on a date, the {{ datepicker.date }} part does not show anything until I manually type something into the input box. I would like it to actively show any date I pick.

下面是一个图像试图解释发生了什么:

Here is an image trying to explain what's happening:

如果有可能,我也想我自己的输入输入到输入框。任何选定的日期将被直接添加到输入框。

If possible, I would also like to type in my own input into the input box. Any selected dates would simply be added into the input box.

推荐答案

请参阅 AngularJS和范围。$适用 和<一个href=\"http://stackoverflow.com/questions/21397361/binding-the-model-value-of-twitter-bootstrap-datepicker-in-controller-in-angular\">answer该相关SO质疑。

&LT;输入&GT; 势必 datepicker.date ,所以当你通过增加直接更新X, {{} datepicker.date} 更新。当您关闭日期选择器,不更改所做的&LT;输入&GT; 所以AngularJS不知道要重新评估前pression。你需要调用范围。$适用明确当日期选择器被关闭。

Your <input> is bound to datepicker.date, so when you update it directly by adding the 'x', {{datepicker.date}} is updated. When you close the datepicker, no changes are made to the <input> so AngularJS doesn't know to re-evaluate the expression. You need to call scope.$apply explicitly when the datepicker is closed.

这篇关于Angularjs与引导,日期选择器:输入不积极被认可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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