不支持调用 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
错误中的错误遇到静态解析符号值.调用函数Angular2SocialLoginModule",不支持函数调用.考虑使用对导出函数的引用替换函数或 lambda,解析/var/www/html/ngtest/src/app/app.module.ts 中的符号 AppModule,解析/var/www/html/ngtest/中的符号 AppModulesrc/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
当我谷歌它时,有人说这是因为在项目中使用了angular 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屋!