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

HttpClient #13

Open
k-schneider opened this issue Jul 22, 2017 · 8 comments
Open

HttpClient #13

k-schneider opened this issue Jul 22, 2017 · 8 comments

Comments

@k-schneider
Copy link

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
Copy link

Tarnn commented Jul 26, 2017

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

@dahang
Copy link

dahang commented Jul 28, 2017

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
Copy link
Contributor

This should be solved by now with #14 PR.

@PunkHaz4rd
Copy link

PunkHaz4rd commented Aug 3, 2017

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
Copy link
Contributor

Murazaki commented Aug 4, 2017

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

@rodrigoreal
Copy link

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
Copy link

@rodrigoreal yes I changed for ng2-translate

@Murazaki
Copy link
Contributor

Murazaki commented Aug 5, 2017

@angular/common/http is only available in angular 4.3+.
For prior versions, you should use ngx-translate/[email protected].

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants