, 내가 추가하고 사용자 정의 필터 : 그러나 그것은 여기에 작동하지 않는 것 것은 내가 달성하기 위해 노력하고 있습니다 무엇의 작은 exapmple이다.
다음은 맞춤 필터입니다.
$scope.filters = [];
$scope.$watch('filter.search', function(newValue, oldValue) {
if(newValue != undefined){
$scope.filters = newValue.split(" ");
}
})
$scope.searachData = {};
$scope.customSearch = function(item) {
$scope.searachData.status = true;
angular.forEach($scope.filters, function(value1, key) {
$scope.searachData.tempStatus = false;
angular.forEach(item, function(value2, key) {
var dataType = typeof(value2);
if(dataType == "string" && (!value2.includes('object'))){
if(value2.toLowerCase().includes(value1)){
$scope.searachData.tempStatus = true;
}
}else if(dataType == "object"){
var num = value2.value.toString();
if(num.includes(value1)){
$scope.searachData.tempStatus = true;
}
}
});
$scope.searachData.status = $scope.searachData.status & $scope.searachData.tempStatus;
});
return $scope.searachData.status;
};
여기에 작동은 Example입니다.
컨트롤러 코드를 추가하십시오. – nextt1
나는 md-data-table에이 코드 펜을 사용하고있다. http://codepen.io/anon/pen/qbLaMb 내가 추가하는 것은 검색 입력 필드인데, 데이터를 필터로 사용하려고 시도한다. – Flash
http : // /codepen.io/next1/pen/OpyQXW 작동 중입니다 – nextt1