crear pipe para filtrado
This commit is contained in:
		
							parent
							
								
									572ba5362d
								
							
						
					
					
						commit
						4a0e6a2c81
					
				|  | @ -0,0 +1,18 @@ | ||||||
|  | import { Pipe, PipeTransform, Injectable } from '@angular/core'; | ||||||
|  | 
 | ||||||
|  | @Pipe({ | ||||||
|  |   name: 'filter', | ||||||
|  | }) | ||||||
|  | @Injectable() | ||||||
|  | export class FilterPipe implements PipeTransform { | ||||||
|  |   transform(items: any[], field: string, value: string): any[] { | ||||||
|  |     if (!items) { | ||||||
|  |       return []; | ||||||
|  |     } | ||||||
|  |     if (!field || !value) { | ||||||
|  |       return items; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return items.filter(singleItem => singleItem[field].toLowerCase().includes(value.toLowerCase())); | ||||||
|  |   } | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue