我有自定义过滤器:
errorReporter.filter('customDateFilter', function () {
return function (input) {
var input1 = parseInt(input.substring(6)); //da makne onaj /Date početak
var jsDate = new Date(input1);
var day = jsDate.getDate();
var month = jsDate.getMonth();
var year = jsDate.getFullYear();
return day.toString() + "." + (month + 1).toString() + "." + year.toString();
};
});
我也有:
<tr class="animate-repeat" ng-repeat="error in latestErrors| orderBy:predicate:reverse|
filter:{ TimeUtc :SearchTimeUtc}">
<td >{{error.TimeUtc | customDateFilter}}</td>
</tr>
And somewhere I have filter input :
<th><input type="text" ng-model="SearchTimeUtc" /></th>
问题是输入I过滤“TimeUtc”而不是“TimeUtc | customDateFilter”。
示例,我有TimeUtc / Date / 5869454458 /和TimeUtc | customDateFilter返回12.07.2014。如果我输入2014内部输入它不会过滤。如果我键入5869,我会进行行筛选。
更新: 我做了这个过滤器: errorReporter.filter('SearchTimeUtcFilter',function(){
return function (input) {
var input1 = parseInt(input.substring(6)); //da makne onaj /Date početak
var jsDate = new Date(input1);
var day = jsDate.getDate();
var month = jsDate.getMonth();
var year = jsDate.getFullYear();
var datum = day.toString() + "." + (month + 1).toString() + "." + year.toString();
$log.info("why doesn't log?");
if (datum.indexOf($scope.SearchTimeUtc) > -1)
return true;
return false;
}
}); 在ng-repeat中:
<tr class="animate-repeat" ng-repeat="error in latestErrors| orderBy:predicate:reverse|
filter:{ TimeUtc :SearchTimeUtcFilter}">
仍然没有:(