Argument of type 'Http' is not assignable to parameter of type 'Http' in Ionic ngx-translate

前端 未结 2 2061
灰色年华
灰色年华 2021-02-13 19:03

I\'m developing an Ionic 2 mobile app and want to use ngx-translate features. Following the tutorial, I\'m importing necessary files in app module like this:

imp         


        
2条回答
  •  眼角桃花
    2021-02-13 19:36

    Try using HttpClient

    import {HttpClientModule, HttpClient} from '@angular/common/http';
    import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
    import {TranslateHttpLoader} from '@ngx-translate/http-loader';
    import {AppComponent} from "./app.component";
    
    export function HttpLoaderFactory(http: HttpClient) {
        return new TranslateHttpLoader(http, "./assets/i18n/", ".json");
    }
    
    @NgModule({
        declarations: [
            AppComponent
          ],
        imports: [
            BrowserModule,
            HttpClientModule,
            TranslateModule.forRoot({
                loader: {
                    provide: TranslateLoader,
                    useFactory: HttpLoaderFactory,
                    deps: [HttpClient]
                }
            })
        ],
        bootstrap: [AppComponent]
    })
    export class AppModule { }
    

提交回复
热议问题