我目前正在使用ionic-timepicker插件为我的离子应用程序创建时间选择器。
不幸的是,我在将当前时间设置为默认值并在用户进行选择时更新值时遇到问题。
有人可以帮我弄清楚出了什么问题吗?
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>
答案 0 :(得分:1)
您是否已将其包含在代码'standardTimeMeridian'指令中?
然后必须将属性etime
绑定到&time; timePickerObject.inputEpochTime&#39;不是未定义的timePickerObject.appointmentTime。
这是一个有效的例子: