0
我有自定義過濾器:如何NG-中繼器的東西通過自定義過濾器過濾,過濾器內
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,我會進行行篩選。
UPDATE: 我提出這個濾波器: errorReporter.filter( 'SearchTimeUtcFilter',函數(){
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-重複裏面:
<tr class="animate-repeat" ng-repeat="error in latestErrors| orderBy:predicate:reverse|
filter:{ TimeUtc :SearchTimeUtcFilter}">
仍然一無所獲:(
。給我看代碼,在ng-repeat過濾器裏面寫什麼? –
http://stackoverflow.com/questions/18792039/angularjs-multiple-filter-with-custom-filter-function –
我做了更新,請問,再看... –