javascript - 将当前时间设置为默认时间并更新值

标签 javascript angularjs ionic-framework

我目前正在使用 ionic-timepicker为我的 Ionic 应用程序创建时间选择器的插件。

不幸的是,我在将当前时间设置为默认时间并在用户做出选择时更新值时遇到问题。

我怎样才能找出问题所在?

enter image description here

controller.js

  $scope.appointmentTime = ((new Date()).getHours() * 60 * 60);

  $scope.timePickerObject = {
    inputEpochTime: ((new Date()).getHours() * 60 * 60), //Optional
    step: 15, //Optional
    format: 12, //Optional
    titleLabel: '12-hour Format', //Optional
    setLabel: 'Set', //Optional
    closeLabel: 'Close', //Optional
    setButtonType: 'button-positive', //Optional
    closeButtonType: 'button-stable', //Optional
    callback: function(val) { //Mandatory
      timePickerCallback(val);
    }
  };

  function timePickerCallback(val) {
    if (val) {
      $scope.timePickerObject.inputEpochTime = val;
    }
  }

book.html

<ionic-timepicker input-obj="timePickerObject">
  <button class="button button-block button-positive overflowShow" style="margin-top: 0px; margin-bottom: 0px">
    <standard-time-meridian etime='timePickerObject.appointmentTime'></standard-time-meridian>
  </button>
</ionic-timepicker>

最佳答案

您的代码中是否包含 'standardTimeMeridian'指令?

然后属性 etime 必须绑定(bind)到 'timePickerObject.inputEpochTime' 而不是未定义的 timePickerObject.appointmentTime。

这是一个工作示例:

http://codepen.io/beaver71/pen/VegagQ

关于javascript - 将当前时间设置为默认时间并更新值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35364318/

相关文章:

javascript - 更正菜单悬停显示

javascript - 绑定(bind)另一个对象的下拉列表

angularjs - 如何手动安装 selenium webdriver-manager?

javascript - Uncaught ReferenceError : Ionic is not defined for Ionic Push

javascript - ionic angular app异步函数中 "this"的范围

javascript - Three.js - 2D + 3D 网格

Javascript:将文本区域转换为数组

javascript - 在 QTP 中评估 JavaScript

javascript - 如何发出多个http请求?

ionic-framework - Ionic - Onesignal - 在handleNotificationReceived上不更新 View