Modified to query the api with the search string
[u/erikhf/frm.git] / src / components / search / SearchService.ts
CommitLineData
690e4045
EHF
1import {provide, Injectable} from 'angular2/angular2';
2import {Http} from 'angular2/http';
3import * as Rx from '@reactivex/rxjs/dist/cjs/Rx';
4
5@Injectable()
6export class SearchService {
690e4045
EHF
7
8 constructor(public http: Http){
9
10 }
11 search(query: string): Rx.Observable<any[]>{
c799c6a5 12 return this.http.get(dhisAPI + "/organisationUnits?paging=false&query=" + query)
690e4045
EHF
13 .map(res=>res.json())
14 .map(res => res.organisationUnits)
c799c6a5 15 .filter(orgunits => orgunits);
690e4045 16
690e4045
EHF
17 }
18}
19
20export var SEARCH_PROVIDERS: Array<any> = [
21 provide(SearchService, {useClass: SearchService})
22];