Javascript 将当前时间设置为默认时间并更新该值
我目前正在使用该插件为我的Ionic应用程序创建一个时间选择器 不幸的是,我在将当前时间设置为默认时间以及在用户进行选择时更新该值时遇到问题 我怎样才能找出问题所在 controller.jsJavascript 将当前时间设置为默认时间并更新该值,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,我目前正在使用该插件为我的Ionic应用程序创建一个时间选择器 不幸的是,我在将当前时间设置为默认时间以及在用户进行选择时更新该值时遇到问题 我怎样才能找出问题所在 controller.js $scope.appointmentTime = ((new Date()).getHours() * 60 * 60); $scope.timePickerObject = { inputEpochTime: ((new Date()).getHours() * 60 * 60),
$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>
您的代码指令中包含了吗 然后属性
etime
必须绑定到'timePickerObject.inputEpochTime'而不是未定义的timePickerObject.AppointTime
以下是一个工作示例: