angularshare-button

ngx-sharebuttons getting No Provider for Http


Using Angular 4, and planning to use ngx-sharebuttons (https://github.com/MurhafSousli/ngx-sharebuttons)

Butt getting this error.

ShareButtonComponent.html:2 ERROR Error: No provider for Http!
    at injectionError (core.es5.js:1169)
    at noProviderError (core.es5.js:1207)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._throwOrNull (

Solution

  • You are missing the http import

    import { HttpModule } from '@angular/http';
    
    @NgModule({
        imports: [ BrowserModule, HttpModule,ShareButtonsModule.forRoot()],// missing http import module
        providers: [],
        declarations: [ AppComponent ],
        bootstrap: [ AppComponent ]
    })
    ....
    

    Demo for The share button link click on contact card

    In the official Wiki link for the share button the HttpModule is required Please check this link