Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling function SocialLoginModule, function calls are not supported.Consider replacing the function or lambda with a reference

Tags:

angular

after "ng serve" or "npm start" i'm getting below error,

enter image description here

after saving any file from work space, it compiles all project files and this time it works well. I'm not getting why this happens. Could you please someone help me to get out of this. Please find below image for the same.

enter image description here

Please find below app.module.ts file

    import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { SocialLoginModule, AuthServiceConfig, GoogleLoginProvider, FacebookLoginProvider } from "angular4-social-login";
import { StarRatingModule } from 'angular-star-rating';
import { AppComponent } from './app.component';
import { LandingPageComponent } from './landing-page/landing-page.component';
import { AppHeaderComponent } from './app-header/app-header.component';
let config = new AuthServiceConfig([
  {
    id: GoogleLoginProvider.PROVIDER_ID,
    provider: new GoogleLoginProvider("")
  },
  {
    id: FacebookLoginProvider.PROVIDER_ID,
    provider: new FacebookLoginProvider("")
  }
]);
export function provideConfig() {
  return config;
}
@NgModule({
  declarations: [
    AppComponent,
    LandingPageComponent,
    AppHeaderComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    StarRatingModule.forRoot(),
    RouterModule.forRoot([
      { path: 'landing', component: LandingPageComponent },
      { path: '', redirectTo: 'landing', pathMatch: 'full' }
    ]),
    SocialLoginModule.initialize(config)
  ],
  providers: [{
    provide: AuthServiceConfig,
    useFactory: provideConfig
  }],
  bootstrap: [AppComponent]
})
export class AppModule { }
like image 911
Sachin Avatar asked Aug 09 '17 17:08

Sachin


1 Answers

add to app.module.ts:

export function provideConfig() {
  return config;
}

update the imports in that file to be:

SocialLoginModule

update providers in that file to be:

  providers: [
    {
      provide: AuthServiceConfig,
      useFactory: provideConfig
    }
  ],

The full snippet can be seen at: https://github.com/abacritt/angular4-social-login/blob/master/README-AOT.md

like image 189
Tomer Ben David Avatar answered Nov 15 '22 04:11

Tomer Ben David