http-loader icon indicating copy to clipboard operation
http-loader copied to clipboard

HttpClient

Open k-schneider opened this issue 7 years ago • 8 comments

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.

k-schneider avatar Jul 22 '17 19:07 k-schneider

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

Tarnn avatar Jul 26 '17 22:07 Tarnn

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, }),

dahang avatar Jul 28 '17 03:07 dahang

This should be solved by now with #14 PR.

Murazaki avatar Jul 28 '17 08:07 Murazaki

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";

PunkHaz4rd avatar Aug 03 '17 13:08 PunkHaz4rd

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

Murazaki avatar Aug 04 '17 18:08 Murazaki

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'.

rodrigoreal avatar Aug 05 '17 16:08 rodrigoreal

@rodrigoreal yes I changed for ng2-translate

PunkHaz4rd avatar Aug 05 '17 17:08 PunkHaz4rd

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

Murazaki avatar Aug 05 '17 22:08 Murazaki