ngx-translate / http-loader

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

Can't resolve all parameters for TranslateHttpLoader #43

Closed devdaddy closed 6 years ago

devdaddy commented 6 years ago

When compiling my code with ionic/cordova I keep getting the error once the Angular Compiler has started:

Can't resolve all parameters for TranslateHttpLoader in 
           /<project-root>/node_modules/@ngx-translate/http-loader/src/http-loader.d.ts:
            ([object Object], ?, ?). 

ng -v info:

Angular CLI: 1.7.3
Node: 8.9.3
OS: darwin x64
Angular: 5.0.0
... compiler, compiler-cli, core, forms, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.3
@angular/common: 5.2.8
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.4.2
webpack: 3.11.0

UPDATE: Here is the app.module.ts

import { Injectable, Injector, NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { HttpModule, Http, RequestOptions } from '@angular/http';
import { HttpClient, HttpClientModule } from "@angular/common/http";
import { TranslateModule, TranslateLoader } from "@ngx-translate/core";
import { TranslateHttpLoader } from "@ngx-translate/http-loader";

import { IEPortal } from './app.component';

export function HttpLoaderFactory(http: HttpClient) {
  return new TranslateHttpLoader(http, './../assets/i18n/', '.json');
}

@NgModule({
  declarations: [
    HomePage
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [ HttpClient ]
      }
    })
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    HomePage
  ],
  providers: [
    { provide: ErrorHandler, useClass: EdgeError },
  HttpClient
  ]
})
export class AppModule {}

I will take any suggestions at this point.

Also, I must have typescript >= 2.4.2 < 2.5.0 for several of my other plugins.

tiaguinho commented 6 years ago

@devdaddy what is the version of ngx-translate? Why are you importing 2 libraries of Angular HTTP?

devdaddy commented 6 years ago

I will answer your second question first. I was importing, but not using the Angular Http v <4.3, just hadn't removed it yet when I posted this.

I am using ngx-translate v9.1.1.

However this can be resolved as I solved this by updating @angular/common to version 5.2.8 and the compiler AoT compiler error went away.

ceaguilera commented 6 years ago

@devdaddy you solved? I have the miss problem