Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

angular - Type HTTPOriginal is not assignable to type Provider, ionic error after plugin installation

After i install the cordova-plugin-advanced-http plugin, when i try to import it on providers in app.modules.ts, i get the following:

Code

I have reinstalled, clean cache, and it keeps happening. Here's the app.module.ts code:

import { HTTP } from '@ionic-native/http';
import { GalleryPageModule } from './../pages/gallery/gallery.module';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';


//providers
import { ImagesProvider } from '../providers/images/images';

//plugins
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { File } from '@ionic-native/file';
import { FileTransfer } from "@ionic-native/file-transfer";
import { AndroidPermissions } from '@ionic-native/android-permissions';
import { SocialSharing } from '@ionic-native/social-sharing';


//firebase
import { firebase } from './../firebase';
import { AngularFireModule } from '@angular/fire';
import { AngularFireDatabaseModule, AngularFireDatabase } from '@angular/fire/database';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { AngularFirestoreModule, AngularFirestore } from '@angular/fire/firestore';
import { ImagenPageModule } from '../pages/imagen/imagen.module';

@NgModule({
  declarations: [
    MyApp,
    HomePage,

  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    HttpClientModule,
    GalleryPageModule,
    AngularFireModule.initializeApp(firebase),
    AngularFireDatabaseModule,
    AngularFireAuthModule,
    AngularFirestoreModule.enablePersistence(),
    ImagenPageModule,
    GalleryPageModule


  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,

  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    HttpClient,
    ImagesProvider,
    AngularFirestore,
    File,
    HTTP,
    FileTransfer,
    AndroidPermissions,
    SocialSharing,



  ]
})
export class AppModule {}

I have tried that in other projects i have, and it works, does not appear that HTTPOriginal suggestion.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You installed the latest @ionic-native/http beta (v5+)

You have to import HTTP from /ngx

import { HTTP } from '@ionic-native/http/ngx';

Otherwise fallback to @ionic-native/http v4+


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...