ng-model的值我試圖讓自定義過濾器過濾日期範圍,保持文本字段獲取popover中用戶的日期。這不起作用,而我有另一個文本框在標題欄中獲取名稱,並且能夠獲取默認過濾器的ng-repeat
中的值。ng-model的值沒有通過ng-repeat
我在這裏錯過了什麼?在Popver
日期字段,沒有任何控制下,它是在popver
<label class=" item-input">
<span class="input-label" style="width:50%;font-size:14px;">From Date</span>
<input type="text" ng-model="fromDate"/>
</label>
HTML - NG-重複
<div ng-repeat="item in Items | filter: custname | filter: applyDateFilter(fromDate, toDate)">
<div class="row item wrap">
<div class="col col-95">
<ion-checkbox ng-model="item.Selected">
<div class="row">
<div class="col col-67">
<p>{{item.name}}</p>
</div>
<div class="col col-33 right">
<p>{{item.order_date | datetimeFormat }}</p>
</div>
</div>
</ion-checkbox>
</div>
</div>
</div>
過濾
FROM日期:.controller("dbController", function($scope, $rootScope) {
$scope.applyDateFilter = function(from, to) {
return function(items, from, to) {
console.log(items);
console.log('from '+from);
console.log('to '+to);
console.log('fromDate '+$scope.fromDate);
console.log('toDate '+toDate);
var result = [];
if(from == 0 && to == 0)
return items;
if(from != '' && to != ''){
var df = parseDate(from);
var dt = parseDate(to);
for (var i=0; i<items.length; i++){
var tf = new Date(items[i].order_date * 1000);
if (tf >= df && tf <= dt) {
result.push(items[i]);
}
}
}
return result;
};
};
});
還通過傳遞像日期時間與過濾器試圖TODATE
.filter('datetime', function($filter){
return function(items, fromDate, toDate){
from = fromDate;
to = toDate;
var result = [];
if(from == 0 && to == 0)
return items;
if(from != '' && to != ''){
var df = parseDate(from);
var dt = parseDate(to);
for (var i=0; i<items.length; i++){
var tf = new Date(items[i].order_date * 1000);
if (tf >= df && tf <= dt) {
result.push(items[i]);
}
}
}
return result;
};
});
提供小提琴來檢查您的流量。 –
你如何打開你的popover?你在使用ui-bootstrap嗎? –