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