-
-
Save amirping/f1d5d697a5962f5d9948b5cd65dcdfd6 to your computer and use it in GitHub Desktop.
pip help
This file contains 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
import { Pipe, PipeTransform } from '@angular/core'; | |
import { radio } from '../classes/radio'; | |
@Pipe({ name: 'searchRadio' }) | |
export class SearchRadioPipe implements PipeTransform { | |
transform(allRadios: radio[] , name :string , location:string) { | |
let result ; | |
let final ; | |
let respat = RegExp(".","g"); // match any thing | |
if(name.length != 0){ | |
respat = RegExp("^.*"+name+".*$","gi"); | |
result = allRadios.filter(radio => radio.name.search(respat)!=-1); | |
} | |
else{ | |
result = allRadios; | |
} | |
// location search from result and not from arg | |
if(location.length != 0){ | |
let locreg = RegExp("^.*"+location+".*$","gi"); | |
final = result.filter(radio => radio.location.search(locreg)!=-1); | |
} | |
else{ | |
final = result ; | |
} | |
return final; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment