annotate src/app/normalization.service.ts @ 48:f8d6f8479e77 ng2-final

first working version with angular 2.4 (using old table w/o pager).
author casties
date Mon, 20 Mar 2017 18:12:48 +0100
parents b65a031c4967
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
dc4f0541f04d update to angular2-rc1. mostly working ;-(
casties
parents: 41
diff changeset
1 import {Injectable} from '@angular/core';
dc4f0541f04d update to angular2-rc1. mostly working ;-(
casties
parents: 41
diff changeset
2 import {Http, Headers} from '@angular/http';
23
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
3
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
4 import 'rxjs/Rx'; // import all RxJS operators
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
5
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 23
diff changeset
6 import {OPENMIND_BASE_URL} from './app-config';
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 23
diff changeset
7
23
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
8 @Injectable()
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
9 export class NormalizationService {
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
10
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
11 constructor(private _http: Http) {}
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
12
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
13 fetchArabicTranslitNormalizedString(text: string) {
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
14 console.debug("fetching arabic translit normalized string: ", text);
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
15 var headers = new Headers();
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
16 headers.append('Accept', 'application/json');
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
17 // put headers in options
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
18 var opts = {'headers': headers};
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
19 // make get request asynchronously
41
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 23
diff changeset
20 var url = OPENMIND_BASE_URL+'jsonInterface?method=normalize_string&type=arabic_translit&text=';
5353b2dffb0f added local configuration file app/app-config.ts.
casties
parents: 23
diff changeset
21 url += encodeURIComponent(text);
23
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
22 var resp = this._http.get(url, opts)
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
23 // filter result as JSON
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
24 .map(res => res.json());
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
25 // return Observable
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
26 return resp;
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
27 }
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
28
f7a7014abf5c normalization service implementation.
casties
parents:
diff changeset
29 }