Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
use rxjs/Observable and change http.get error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
baso10 committed Mar 16, 2018
1 parent f0ade9c commit 2720901
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/http-loader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {HttpClient} from "@angular/common/http";
import {TranslateLoader} from "@ngx-translate/core";
import {Observable} from 'rxjs/Rx';
import {Observable} from 'rxjs/Observable';

export class TranslateHttpLoader implements TranslateLoader {
loadedTranslations: { [index: string]: Object; } = {};
Expand All @@ -27,13 +27,13 @@ export class TranslateHttpLoader implements TranslateLoader {
public preLoad(lang: string): Promise<any> {
return new Promise((resolve, reject) => {
this.http.get(`${this.prefix}${lang}${this.suffix}`)
.catch((error: any): any => {
resolve(null);
})
.subscribe((result) => {
.subscribe(
result => {
this.loadedTranslations[lang] = result;
resolve(result);
});
},
error => {resolve(null)}
);
});
}
}

0 comments on commit 2720901

Please sign in to comment.