Error: No provider for http in constructor parameter with Ionic

后端 未结 2 1578
长情又很酷
长情又很酷 2021-01-27 00:14

I\'m following a tutorial in Portuguese that teaches how to build your first Ionic application.

After installing npm, node.js, angular, Ionic and Cordova using last vers

相关标签:
2条回答
  • 2021-01-27 00:40

    SOLUTION: HTTP_PROVIDERS were removed from angular2 and were replaced by: HttpModule.

    All I had to do was add:

    import { HttpModule } from '@angular/http';
    

    To src/app/app.module.ts and then:

    imports: [
      BrowserModule,
      HttpModule,
      IonicModule.forRoot(MyApp)
    ],
    

    And done. Thank you so much for everyone.

    0 讨论(0)
  • 2021-01-27 00:50

    Use the below code

    import {HTTP_PROVIDERS} from '@angular/http';
    
    provider : [ HTTP_PROVIDERS, ....
    
    
     ]
    

    The above answer was deprecated since angular4. However As I said in the comment,

    import { HttpModule } from '@angular/http';
    
    imports: [ HttpModule ]
    
    0 讨论(0)
提交回复
热议问题