Created
March 28, 2016 20:22
-
-
Save AlexanderArmua/5616c710c709ca718ab7 to your computer and use it in GitHub Desktop.
Revisa una variable y si contiene texto, busca en todos los campos que se le diga en un array y si encuentra coincidencia retorna true para mostrarlo en el filtro. (v1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var filters=["filtro1","filtro2","filtro3","filtro4","filtroN"]; | |
$scope.filtrar=function(object) | |
{ | |
if($scope.filtroTxT.length) | |
{ | |
for (var i = 0; i<filters.length; i++) | |
{ | |
if((object[filters[i]]) && (object[filters[i]]==$scope.filtroTxT))//Revisa cada campo dentro del array y lo busca dentro del objeto. | |
{ | |
return true; | |
} | |
} | |
return false; | |
} | |
else | |
{ | |
return true; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text" placeholder="Filter..." ng-model="filtroTxT"/> | |
<table> | |
<thead> | |
<tr> | |
<th>Filtro 1</th> | |
<th>Filtro 2</th> | |
<th>Filtro 3</th> | |
<th>Filtro 4</th> | |
<th>Filtro N</th> | |
</tr> | |
</thead> | |
<tbody ng-repeat="object in QUERYDB"> | |
<tr>{{object.filtro1}}</tr> | |
<tr>{{object.filtro2}}</tr> | |
<tr>{{object.filtro3}}</tr> | |
<tr>{{object.filtro4}}</tr> | |
<tr>{{object.filtroN}}</tr> | |
</tbody> | |
</table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment