gpt4 book ai didi

angular - 不支持调用 Angular2SocialLoginModule 函数调用

转载 作者:太空狗 更新时间:2023-10-29 19:34:46 26 4
gpt4 key购买 nike

我是 Angular js2 的新手。目前我正在使用一个 web 应用程序,它使用 angular2 作为前端。在此应用程序中,我使用 angular2-social-login 进行身份验证。但是当我运行 npm start 时,出现以下错误

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了一下,有人说是因为在项目中使用了angular cli。但是我卸载了angular cli,问题仍然存在。有没有人知道如何解决这个问题?

我的 app.module.ts 代码如下

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文件

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.
}
)}
}

以上是我的代码,请看一下。如果需要更多详细信息,请评论

最佳答案

更新

在 angular2-social-login v.3.0.0 中你可以这样写:

@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);
}
}

关于angular - 不支持调用 Angular2SocialLoginModule 函数调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42688744/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com