嗨,我有一个包含数据的表,我要用什么来过滤结果,这样如果一个表行的日期时间不是当前的日期,那么特定的行不能显示或者只需更改它的背景颜色。这是我尝试过但它不起作用。即使它没有过滤我可以使用的其他东西?基本上第一行必须出现
<table class="table table-striped table-bordered table-hover table-fixedheader">
<thead>
<tr>
<th>KomaxShortname</th>
<th>OriginalFileName</th>
<th>OriginalPath</th>
<th>OriginalModifiedDateTime</th>
<th>UpLoadedDateTime</th>
<th>AgeInMinutes</th>
<th>FileLength</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="latestwpcsfiles in Model.WpcsFiles | filter:{OriginalModifiedDateTime:'!CurrentDateTime'}">
<td>{{latestwpcsfiles.KomaxShortname}}</td>
<td>{{latestwpcsfiles.OriginalFileName}}</td>
<td>{{latestwpcsfiles.OriginalPath}}</td>
<td>{{latestwpcsfiles.OriginalModifiedDateTime}}</td>
<td>{{latestwpcsfiles.UpoadedDateTime}}</td>
<td>{{latestwpcsfiles.AgeInMinutes}}</td>
<td>{{latestwpcsfiles.FileLength}}</td>
</tr>
</tbody>
</table>
JS
function Model($http) {
var self = this;
self.$http = $http;
self.WpcsFiles = [];
self.GetLatestWpcsFiles = function () {
return ngHesto.Ajax.Get(self.$http
, {
url: 'http://10.19.13.68/GetLatestWpcsFiles/Default.aspx'
, success: function (data) {
self.WpcsFiles = data.data;
console.log(self.WpcsFiles);
}
});
}
self.GetLatestWpcsFiles();
}
ngAppModule.controller('LatestWpcsFilesController', ['$scope', '$http', function ($scope, $http) {
$scope.Model = new Model($http);
}]);
答案 0 :(得分:0)
imo最简单的方法是创建一个custom filter,如下所示:
function(items, date) {
var result = [];
if (items != null) {
for (var i = 0; i < items.length; i++;){
var item = items[i];
if (item.OriginalModifiedDateTime.getDate() == date.getDate())
result.push(item);
}
}
return result;
}