ngx-translate / http-loader

A loader for ngx-translate that loads translations with http calls
MIT License
191 stars 69 forks source link

HttpClient #13

Open k-schneider opened 7 years ago

k-schneider commented 7 years ago

Would be nice for people that have updated to use the new HttpClient in @angular/common/http to have a separate loader here that uses it instead of Http.

Tarnn commented 7 years ago

Was thinking the same thing, realized my httploader will no longer work

dahang commented 7 years ago

for 1.0.0 http-loader start to using Angular 4.3 HttpClientModule. so in app.module.ts import { HttpClient, HttpClientModule } from "@angular/common/http"; export function createTranslateLoader(http: HttpClient) { return new TranslateHttpLoader(http, './assets/i18n/', '.json'); }

@NgModule({ imports: [ ... HttpClientModule ... TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: (createTranslateLoader), deps: [HttpClient] }, missingTranslationHandler: {provide: MissingTranslationHandler, useClass: MyMissingTranslationHandler}, useDefaultLang: false, }),

Murazaki commented 7 years ago

This should be solved by now with #14 PR.

PunkHaz4rd commented 7 years ago

Tried using it on ionic 2:

Typescript Error Cannot find module '@angular/common/http'.

in node_modules/@ngx-translate/http-loader/src/http-loader.d.ts import { HttpClient } from "@angular/common/http";

Murazaki commented 7 years ago

You should use import { HttpClient, HttpClientModule } from '@angular/common/http';

rodrigoreal commented 7 years ago

I'm having also the same problem as @PunkHaz4rd using ionic

Typescript Error
Cannot find module '@angular/common/http'.
node_modules/@ngx-translate/http-loader/src/http-loader.d.ts

@PunkHaz4rd did you find a way to get it to work?

@Murazaki Sorry, but i didn't understand what you want us to do. Where should i import it? I tried to import it on the app.module.ts but i get an error:


Cannot find module '@angular/common/http'.
PunkHaz4rd commented 7 years ago

@rodrigoreal yes I changed for ng2-translate

Murazaki commented 7 years ago

@angular/common/http is only available in angular 4.3+. For prior versions, you should use ngx-translate/http-loader@0.1.0.