]> git.uio.no Git - u/erikhf/frm.git/blob - src/components/search/SearchService.ts
Fixed bugs where searchresult did not update, where searchlist got duplicated when...
[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 + "/api/organisationUnits?paging=false&filter=name:like:" + query)
13             .map(res=>res.json())
14             .map(res => res.organisationUnits)
15             .filter(orgunits => orgunits);
16     }
17 }
18
19 export var SEARCH_PROVIDERS: Array<any> = [
20     provide(SearchService, {useClass: SearchService})
21 ];