Mercurial > hg > ng2-query-ismi
diff src/app/normalization.service.ts @ 49:781a5387ca93
Merge with angular2-final branch
f8d6f8479e77011fd043c5feb2b14a476d0aaffc
author | casties |
---|---|
date | Mon, 20 Mar 2017 18:50:31 +0100 |
parents | b65a031c4967 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/app/normalization.service.ts Mon Mar 20 18:50:31 2017 +0100 @@ -0,0 +1,29 @@ +import {Injectable} from '@angular/core'; +import {Http, Headers} from '@angular/http'; + +import 'rxjs/Rx'; // import all RxJS operators + +import {OPENMIND_BASE_URL} from './app-config'; + +@Injectable() +export class NormalizationService { + + constructor(private _http: Http) {} + + fetchArabicTranslitNormalizedString(text: string) { + console.debug("fetching arabic translit normalized string: ", text); + var headers = new Headers(); + headers.append('Accept', 'application/json'); + // put headers in options + var opts = {'headers': headers}; + // make get request asynchronously + var url = OPENMIND_BASE_URL+'jsonInterface?method=normalize_string&type=arabic_translit&text='; + url += encodeURIComponent(text); + var resp = this._http.get(url, opts) + // filter result as JSON + .map(res => res.json()); + // return Observable + return resp; + } + +} \ No newline at end of file