2016-02-12 62 views
4

我目前使用的ionic-timepicker插件創建我的離子應用時間選擇器。設置當前時間爲默認值和更新值

不幸的是,我有問題設置當前時間爲默認,當用戶選擇更新值。

有人可以請幫我找出什麼是錯的?

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> 

回答