不支持调用Angular2SocialLoginModule函数调用 [英] Calling Angular2SocialLoginModule function calls not supported
问题描述
我是angular js2的新手.目前,我正在使用Web应用程序,该应用程序将angular2用作前端.在此应用程序中,我已使用angular2-social-login进行身份验证.但是,当我运行npm start时,出现以下错误
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遇到静态解析符号值的情况.调用函数"Angular2SocialLoginModule",不支持函数调用.考虑使用对导出函数的引用替换函数或lambda,在/var/www/html/ngtest/src/app/app.module.ts中解析符号AppModule,在/var/www/html/ngtest/中解析符号AppModule src/app/app.module.ts
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
当我在Google上搜索它时,有人说这是因为在项目中使用了角度cli.但是我卸载了angular cli,问题仍然存在. 有人知道如何解决这个问题吗?
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?
我的app.module.ts代码在下面
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 { }
我已经在header.component.ts中调用了此模块,请参阅header.component.ts文件
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
推荐答案
更新
在angular2-social-login v.3.0.0中,您可以编写:
Update
In angular2-social-login v.3.0.0 you can write:
@NgModule({
...
imports: [
Angular2SocialLoginModule
]
})
export class AppModule {
constructor(){}
}
Angular2SocialLoginModule.loadProvidersScripts(providers);
旧版本
删除
imports: [
Angular2SocialLoginModule.initWithProviders(providers),
],
并尝试以下操作:
import { Angular2SocialLoginModule, AuthService } from "angular2-social-login";
@NgModule({
...
providers: [
AuthService
]
})
export class AppModule {
constructor() {
Angular2SocialLoginModule.initWithProviders(providers);
}
}
这篇关于不支持调用Angular2SocialLoginModule函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!