2014-10-20 63 views
0

我的目標是檢查特定日期對象是否在時間範圍內,然後在頁面上顯示右側按鈕作爲結果。將給定的日期對象與當天的特定時間進行比較

目前,我有這樣的:

ng-if="payment.TransactionDateTime <= *Six PM on the same day* && payment.TransactionDateTime >= *Six PM The Day before the payment.TransactionDateTime*" 

我應該怎麼做才能使這項工作?我需要檢查支付的TransactionDateTime屬性前一天的下午6點和TransactionDateTimeProperty的同一天下午6點之間是否發生付款。

回答

0

在您的控制器中,獲取事務日期時間並創建要比較的範圍變量。我不確定你有什麼格式的TransactionDateTime,但這是一個基本的示例代碼。

if(!payment.TransactionDateTime) { 
    var transactionDay = new Date(Date.parse(payment.TransactionDateTime)); 
    $scope.beforeSixSameDay = transactionDay.setHours(18); 
    $scope.afterSixDayBefore = new Date().setDate(transactionDay - 1).setHours(18); 
} 

在你的HTML頁面,

<div ng-if="payment.TransactionDateTime <= beforeSixSameDay && payment.TransactionDateTime >= afterSixDayBefore"></div>