角引导时间选取不具约束力的时间 [英] Angular Bootstrap Time Picker not Binding time

查看:127
本文介绍了角引导时间选取不具约束力的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能够绑定的时间,我在这样的控制器

I'm not able to bind time which I'm setting in the controller like this

 $scope.info.startTime="12:10:03";

这是在HTML我的时间选择器控件

This is my time picker control in HTML

<span class="input-group">
          <input type="text" class="form-control" datepicker-popup="{{format}}"  tabindex="5"
                 ng-model="info.startTime" placeholder="hh:mm"
                 is-open="datepickerOpened1"
                 close-text="Close"/>
          <span class="input-group-btn">

            <button type="button" class="btn btn-default dropdown-toggle" ng-click="openStartTime($event, 'time')">
                <i class="glyphicon glyphicon-time"></i>
            </button>
                <div dropdown is-open="timepickerOpened1">
              <span class="dropdown-menu" role="menu">
                  <timepicker ng-model="info.startTime"  show-meridian="true"></timepicker>
              </span>
            </div>
          </span>
        </span>

参考:角引导

推荐答案

您需要设置日期对象在NG-模型而不是字符串。

You need to set date object in ng-model instead of string.

修改

$scope.info.startTime="12:10:03";

var d = new Date();
d.setHours(12);
d.setMinutes(10);
$scope.info.startTime=d;

这篇关于角引导时间选取不具约束力的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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