Angular2SocialLoginModule function call is not supported
I am new to angular js2. I am currently working with a web application that uses angular2 for the front end. In this application, I have used angular2-social-login for authentication purposes. But when I run npm run I got the following error
Error in error. The caller "Angular2SocialLoginModule" function calls are not supported. Consider replacing the function or lambda with a reference to the exported function, resolving the AppModule symbol in /var/www/html/ngtest/src/app/app.module.ts, resolving the AppModule symbol in / var / www / html / ngtest / src / app /app.module.ts
When I google about this, someone says it has to do with using the angular cli in the project. But I removed the angular cli, the problem still persists. Does anyone know how to fix this problem?
My app.module.ts code is below
import { Angular2SocialLoginModule } from "angular2-social-login";
let providers = {
"facebook": {
"clientId": "xxxxxxxxxxxxx",
"apiVersion": "v2.8"
},
"linkedin": {
"clientId": "xxxxxxxxxxx"
},
"google": {
"clientId": "xxxxxxxxxx"
}
};
@NgModule({
imports: [
Angular2SocialLoginModule.initWithProviders(providers),
],
})
export class AppModule { }
I named this module in header.component.ts, see header.component.ts file
import { AuthService } from "angular2-social-login";
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.css'],
providers: [Modal]
})
export class HeaderComponent implements OnInit {
constructor(public _auth: AuthService){ }
signIn(provider){
this.sub = this._auth.login(provider).subscribe(
(data) => {
console.log(data);
}
)}
logout(){
this._auth.logout().subscribe(
(data)=>{
//return a boolean value.
}
)}
}
Above is my code please see. If more details are required please comment
source to share
Update
In angular2-social-login v.3.0.0 you can write:
@NgModule({
...
imports: [
Angular2SocialLoginModule
]
})
export class AppModule {
constructor(){}
}
Angular2SocialLoginModule.loadProvidersScripts(providers);
Old version
Delete
imports: [
Angular2SocialLoginModule.initWithProviders(providers),
],
And try this:
import { Angular2SocialLoginModule, AuthService } from "angular2-social-login";
@NgModule({
...
providers: [
AuthService
]
})
export class AppModule {
constructor() {
Angular2SocialLoginModule.initWithProviders(providers);
}
}
source to share