Calling Angular2SocialLoginModule function calls not supported

孤人 提交于 2019-12-04 04:10:19

问题


I am new to angular js2. Currently I am working with a web application, which uses angular2 for front-end. In this application I have used angular2-social-login for authentication purpose. But when I run the npm start I got the below error

ERROR in Error encountered resolving symbol values statically. Calling function 'Angular2SocialLoginModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in /var/www/html/ngtest/src/app/app.module.ts, resolving symbol AppModule in /var/www/html/ngtest/src/app/app.module.ts

When I google it, some one says that it is beacause of using angular cli in the project. But I uninstalled angular cli, still problem persists. Did any one know how to solve this issue?

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 have called this module in header.component.ts, please see the 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.
}
)}
}

The above is my code, Please have a look. If any more details needed please comment


回答1:


Update

In angular2-social-login v.3.0.0 you can write:

@NgModule({
  ...
  imports: [ 
     Angular2SocialLoginModule
  ]
})
export class AppModule { 
  constructor(){}
}

Angular2SocialLoginModule.loadProvidersScripts(providers);

Old version

Remove

imports: [
  Angular2SocialLoginModule.initWithProviders(providers),
],

And try this:

import { Angular2SocialLoginModule, AuthService } from "angular2-social-login";

@NgModule({
  ...
  providers: [
    AuthService
  ]
})
export class AppModule {
  constructor() {
    Angular2SocialLoginModule.initWithProviders(providers);
  }
}



回答2:


It worked for me.

export class AppModule {
    constructor() {
        Angular2SocialLoginModule.initWithProviders(providers);
    }
}



回答3:


Another solution to fix the above problem:

export class AppModule {
 constructor() {
}}
Angular2SocialLoginModule.initWithProviders(providers);


来源:https://stackoverflow.com/questions/43580314/calling-angular2socialloginmodule-function-calls-not-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!