2016-12-21 116 views
-2

我有json的日期表,我需要做2個輸入,這將填入此日期從。防爆。在1990年進入第一個輸入之後,並且在我的表格中的第二個輸入2016年將僅爲1990年到2016年的日期。 從代碼中看起來如何? 在此先感謝!來自過濾角度的日期

+0

什麼是你已經在你的代碼加入?添加它?之前問建議你看到這個鏈接http://stackoverflow.com/help/how-to-ask – Aravind

+0

請發佈你到目前爲止嘗試過的東西 –

回答

0

讓我們假設你有一個名爲datesArray的日期數組。

<div> 
    <input ng-model="dateFilter.from" class="form-control" /> 
    <input ng-model="dateFilter.to" class="form-control" /> 

    <div ng-repeat="date in datesArray | filterBy:dateFilterFunction"> 
     {{date}} 
    </div> 
</div> 

控制器:

$scope.dateFilter={}; 
$scope.dateFilterFunction= function(date){ 
    return (date>$scope.dateFilter.from && date<$scope.dateFilter.to) 
} 
+0

我想你的HTML大寫是錯誤的,你會替換dateFilter函數。我猜這些模型應該是datefilter.from和datefilter.to,都是小寫。 – Helvio

+1

你是對的。編輯。 –